proxy_cache only if custom header is set by upstream

ThomasLohner nginx-forum at
Tue May 15 16:24:51 UTC 2012

Yeah! Thanks, maybe you should add to the wiki, that "if" is executed
before proxy_pass ;-)

Anyways, thank you very much for this helpful answer, it works this

obviously the map has to be the other way around, so if anyone finds
this.. the correct way for caching only if upstream sets a custom header

map $upstream_http_myheader $nocache {
default 1;
1 0;

proxy_no_cache $nocache;

Posted at Nginx Forum:,226461,226467#msg-226467

More information about the nginx mailing list