Response Header IF statement problem

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


Hi,

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
$upstream_http_x_secured_page
 -
http://nginx.org/en/docs/http/ngx_http_upstream_module.html#var_upstream_http_

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. 
 - http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_no_cache

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: https://forum.nginx.org/read.php?2,278558,278561#msg-278561



More information about the nginx mailing list