How to Avoid Crazy Caching with "Vary: Cookie" Header in NGINX
You should look at the directives proxy_no_cache
and proxy_cache_bypass
.
proxy_no_cache
tells nginx the conditions under which it should not cache the response from your app. You can define this to be just about whatever you wish, e.g.:
proxy_no_cache $cookie_sessionid;
proxy_cache_bypass
operates in the other direction: it tells nginx when a request should not be served from cache but instead passed on to your app, even if a cached entry exists.