Welcome! Log In Create A New Profile

Advanced

Re: http 500 errors are not cached but go to the backend

Maxim Dounin
January 04, 2013 05:32PM
Hello!

On Fri, Jan 04, 2013 at 08:38:53AM -0500, brama wrote:

> I've set up nginx (tested with 1.2.6 and 1.3.10) to cache all requests to
> our fastcgi backends. If a cache entry expires, stale entries wil be served
> while nginx is updating the cache. I'm using the fastcgi_cache_lock feature
> to make sure only 1 request will be sent to the backend to update the
> cache.

Just a side note: the fastcgi_cache_lock directive doesn't affect
update of the cache, it only affects adding new items to the
cache. To handle cache updating the "fastcgi_cache_use_stale
updating" should be used (it's actually already in your config).

[...]

> This seems counter-intuitive. If the http 500 document expires, nginx should
> serve the stale cache entry until it has updated the cache entry. However,
> with http_500 included in fastcgi_cache_use_stale, it never appears to
> update the cache entry at all. Bug?

The

fastcgi_cache_use_stale http_500;

in your config instructs nginx to don't cache 500 response but
return stale cached content instead. As soon as original cached
resource expires - nginx starts to ask backend about new response,
but since 500 is returned it returns stale response to clients
instead.

In your case the behaviour looks a bit confusing as "original
cached resource" above is the same 500 response (cached as
fastcgi_cache_use_stale don't affect initial content caching), but
the behaviour is as expected with your configuration - when you
ask nginx to cache 500 responses and to don't use 500 responses
for cache update at the same time.

--
Maxim Dounin
http://nginx.com/support.html

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

http 500 errors are not cached but go to the backend

brama January 04, 2013 08:38AM

Re: http 500 errors are not cached but go to the backend

Maxim Dounin January 04, 2013 05:32PM

Re: http 500 errors are not cached but go to the backend

brama January 08, 2013 05:19AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 217
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready