Skip to content

Instantly share code, notes, and snippets.

@anop72
Last active May 6, 2019 05:59
Show Gist options
  • Save anop72/c9b90caf0b6e32f2027a to your computer and use it in GitHub Desktop.
Save anop72/c9b90caf0b6e32f2027a to your computer and use it in GitHub Desktop.
nginx use cookie as cache key
# guide https://www.nginx.com/blog/nginx-caching-guide/
# document for variable http://nginx.org/en/docs/http/ngx_http_core_module.html#Variables
server {
...
location / {
# point is cookie name shouldn't contain - (hyphen), it cause wrong hash key.
# example $cookie_gist_var
proxy_cache_key $proxy_host$request_uri$cookie_{cookieNameShouldNotContainHyphen};
...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment