proxy_cache_bypass and proxy_no_cache
Antonio P.P. Almeida
appa at perusio.net
Mon Dec 10 14:09:27 UTC 2012
> One interesting observation
>
> I put this code
>
> location /test {
> proxy_pass http://a/;
> ....
> set $dont_cache 1;
>
> if ( $cookie_route ) {
> set $dont_cache 0;
> }
> proxy_cache_bypass $dont_cache;
> proxy_no_cache $dont_cache;
>
> }
>
> and it started to dis-honour the trailing slash http://a/ With the end /
> it
> does not look for /test but only due to the if block it started to look
> for
> it.
You have to set it at the server level to make it work.
set $dont_cache 1;
if ($cookie_route) {
set $dont_cache 0;
}
location /test {
proxy_pass http://a/;
proxy_cache_bypass $dont_cache;
proxy_no_cache $dont_cache;
}
If creates an implicit location.
If is evil: http://wiki.nginx.org/IfIsEvil
As Igor said above use map and get clear of the if directive quirks.
--appa
More information about the nginx
mailing list