Response Header IF statement problem

webopsx nginx-forum at
Wed Feb 14 15:03:02 UTC 2018


If I understand correctly you actually don't want to cache specific
responses (not bypass). The proxy_cache_bypass is only for if the response
has already been cached and defines the behavior in which NGINX should serve
the cached version to a client. 

Therefore if I understand correctly, you should be using the upstream module
for your origin definition and the proper variable will be available as

Then use the proxy_no_cache directive to determine what should and should
not be cached in your configuration. If you want to simply check if the
header exists and then not cache the response, you can add the
upstream_http_ variable as a parameter. 

If you need to inspect the header, then look into using map instead to
define the conditions you need in other to set or not set the proxy_no_cache
to a value or not.

Please let me know if my understanding is correct.

Posted at Nginx Forum:,278558,278561#msg-278561

More information about the nginx mailing list