How to determine when the response from the cache

xore nginx-forum at
Sat May 12 13:56:07 UTC 2012

Chris, thank you, this is what i need.

By the way, i found one strange thing - operator "if" don't work with
For example, i try to change "HIT" and "MISS" to more enigmatic values

set $tocache X;
if ($upstream_cache_status = HIT)
  set $tocache H;

if ($upstream_cache_status = MISS)
  set $tocache M;

add_header tocache "$tocache ($upstream_cache_status)";

I expected to see "tocache: M (MISS)" and "tocache: H (HIT)".
But i got "tocache: X (MISS)" and "tocache: X (HIT)".

Maybe "if" works not for any variable?

Posted at Nginx Forum:,226331,226344#msg-226344

More information about the nginx mailing list