Skip to content

Instantly share code, notes, and snippets.

@wateryoma
Forked from anop72/nginx.conf
Created January 16, 2017 23:15
Show Gist options
  • Save wateryoma/918349a192e30941fb2630b18d87b5d6 to your computer and use it in GitHub Desktop.
Save wateryoma/918349a192e30941fb2630b18d87b5d6 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