sent_http_HEADER Volatile under Nginx 1.2.4

Maxim Dounin mdounin at
Mon Dec 16 11:12:33 UTC 2013


On Mon, Dec 16, 2013 at 09:22:25AM +0000, Paul Taylor wrote:

> Yup, again, you’re right! I’ve moved the config around, so that I’m testing for any ‘true’ value in the proxy_no_cache & proxy_bypass_cache directives (removing the existing set_by_lua block).
> However, it’s still not behaving as I’d expect.
> In the following scenario (note comments):
> map $upstream_http_x_no_cache $no_cache_header {
>     ""                    0;
>     default               1;
> }
> proxy_cache_bypass    $no_cache_dirs $logged_in; # $no_cache_header;
> proxy_no_cache	      $no_cache_dirs $logged_in; # $no_cache_header;
> X-Cache-Status value is MISS, which is correct. Output of $no_cache_header is 1 (as set in the map).
> However, when adding back in the compare on $no_cache_header:
> proxy_cache_bypass    $no_cache_dirs $logged_in $no_cache_header;
> proxy_no_cache	      $no_cache_dirs $logged_in $no_cache_header;
> X-Cache-Status value is still MISS, which is not correct, as it should be BYPASS. Output of $no_cache_header is 0.
> Unless I’m missing something, it still looks like touching the variable kills it?

The proxy_cache_bypass directive is expected to be checked before 
a request is sent to a backend - it is to control whether a 
request will be served from a cache or passed to a backend.

That is, what you see is actually expected behaviour - there are 
no reasons X-Cache-Status to be BYPASS, and the cached 
$no_cache_header value to be different from 0.

Maxim Dounin

More information about the nginx mailing list