fastcgi_cache_bypass and 502 Bad Gateway

kaspars nginx-forum at
Thu Feb 10 15:08:56 MSK 2011

Using Nginx 0.8.54.

I'm trying to use fastcgi_cache_bypass with an HTTP header for Nginx to
request a new response from the backend and cache it.

if ($http_cookie ~*
"comment_author_|wordpress_(?!test_cookie)|wp-postpass_" ) {
  set $donot_cache 1;

fastcgi_cache   cachetitle;
fastcgi_cache_key   $scheme$host$request_uri;
fastcgi_no_cache   $donot_cache; # do no cache at all
fastcgi_cache_bypass   $http_cache_bypass; # bypass cache and cache the
new response
fastcgi_cache_use_stale  error timeout invalid_header http_500;
fastcgi_cache_min_uses  1;

It does seem to work -- I see a fresh page returned from the backend,
but on the second request without the header I get a 502 Bad Gateway

I also noticed that on Nginx wiki page there is no reference to 
fastcgi_cache_bypass, although I saw it there just a few days ago.

Is this feature being removed or postponed for later? Is it available in
the latest dev version?


Posted at Nginx Forum:,173795,173795#msg-173795

More information about the nginx mailing list