Using NginX as a reverse proxy, I want to cache the response ONLY if the
user has NOT logged in, which can be checked by testing the existence of
a
cookie.
First I tried to use “if”, but NginX complained that I cannot put a
proxy_cache_valid inside an “if”:
Then I tried to set the cache-duration to 0s by using a variable, but
then
NginX complained the time value is incorrect.
set $cacheDuration 60m;
if ($cookie_login != ‘’) {
set $cacheDuration 0s;
}