using $upstream* variables inside map directive

Kirill K. nginx-forum at nginx.us
Wed May 7 05:38:04 UTC 2014


Hello,
I'm trying to avoid caching of small responses from upstreams using map:
map $upstream_http_content_length $dontcache {
default 0;
~^\d\d$ 1;
~^\d$ 1;
}

Unfortunatelly, nginx seems to ignore $upstream* variables at the map
processing stage, hence variables like $upstream_http_content_length or
$upstream_response_length stay empty when map directive is processed (this
can be observed in debug log as "http map started" message). In case I use
non-upstream related variables, a map works as expected.

Question: is there any way to use $upstream* vars inside the map directive,
or maybe someone can offer alternative way to detect small upstream response
in order to bypass cache?

Thank you.

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,249880,249880#msg-249880



More information about the nginx mailing list