fastcgi_cache_bypass and 502 Bad Gateway

Maxim Dounin mdounin at mdounin.ru
Sat Feb 12 03:06:52 MSK 2011


Hello!

On Fri, Feb 11, 2011 at 09:49:54PM +0000, António P. P. Almeida wrote:

> On 11 Fev 2011 16h57 WET, nginx-forum at nginx.us wrote:
> 
> > The point I was trying to make is that in this case for instance,
> > ...
> >
> > [code]
> > set $donot_cache 0;
> > if ($http_cookie ~*
> > "comment_author_|wordpress_(?!test_cookie)|wp-postpass_" ) {
> > set $donot_cache 1;
> > }
> > set $test $donot_cache;
> > [/code]
> >
> > ... $test will always be equal to 0 as any variable set within the
> > 'if' block is not exposed outside the block AFAIK.
> >
> > So when you run ...
> >
> > [code]
> > set $donot_cache 0;
> > if ($http_cookie ~*
> > "comment_author_|wordpress_(?!test_cookie)|wp-postpass_" ) {
> > set $donot_cache 1;
> > }
> 
> 
> This is because as Maxim, and agentzh have explained before: an if is
> an *implicit location*. So what you're requesting above is for a
> variable with a value changed at a lower level (implicit location) be
> visible at an upper level (containing location).
> 
> My understanding of Nginx scoping is that it works in one direction,
> i.e., you can only be sure that this works global -> http -> server ->
> location -> if in location.
> 
> There's no reverse path for inheriting variables set at a lower level
> on a higher level.
> 
> Can someone more knowledgeable than I concur and straighten me if I'm
> incorrect?

You are incorrect.  Variables are property of request.  They are 
either set during request processing or not, and if set - they are 
visible to all operations with request.

Maxim Dounin



More information about the nginx mailing list