Nginx multiple upstream map conditions

c0nw0nk nginx-forum at
Wed Aug 31 22:44:50 UTC 2016

Francis Daly Wrote:
> On Wed, Aug 31, 2016 at 01:30:30PM -0400, c0nw0nk wrote:
> Hi there,
> > Thanks works a treat is it possible or allowed to do the following
> in a
> > nginx upstream map ? and if so how i can't figure it out.
> I think it is logically impossible.
> > I cache with the following key.
> > fastcgi_cache_key
> > "$session_id_value$scheme$host$request_uri$request_method";
> fastcgi_cache_key is the thing that nginx calculates from the request,
> before it decides whether to send the response from cache, or whether
> to pass the request to upstream.
> > if the upstream_cookie_logged_in value is not equal to 1 how can I
> set
> > $session_id_value ''; make empty
> $upstream_cookie_something is part of the response from upstream,
> so is not available to nginx at the time that it is calculating
> fastcgi_cache_key for the "read from cache or not" decision.
> Am I missing something?
> 	f
> -- 
> Francis Daly        francis at
> _______________________________________________
> nginx mailing list
> nginx at

Thanks :) so changes to that value will have no effect.

What about the following scenario.

I remove all Set-Cookie headers.
fastcgi_hide_header Set-Cookie;

Then add them back in with :
add_header Set-Cookie "$upstream_http_set_cookie";

Will requests that get a cache hit ever contain a Set-Cookie header or isit
only the ones that reach the origin php server.

>From my tests it appears to be working that no set-cookie headers are
present on "X-Cache-Status : HIT" headers.

Posted at Nginx Forum:,269296,269328#msg-269328

More information about the nginx mailing list