sent_http_HEADER Volatile under Nginx 1.2.4

Paul Taylor me at
Mon Dec 16 12:38:59 UTC 2013

Hi Maxim,

Ok, thanks for the clarification.

So to confirm, we are looking for the value of the sent header from the upstream, to identify whether the content should be served from the cache, or the upstream. Does this therefore mean that the code that we have below, will check for the X-No-Cache header, and if present, will always render the content from the upstream (no cache), and that if not present, will enable the result to be cacheable? If so, and it is only the reporting of the X-Cache-Status value that is rendering a false value, then this will give us what we want?

If not, then what suggestions would you have for caching only on the basis of this sent http header being present?

Thanks again…nearly there ;)


On 16 Dec 2013, at 11:12, Maxim Dounin <mdounin at> wrote:

> Hello!
> 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
> _______________________________________________
> nginx mailing list
> nginx at

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the nginx mailing list