[NGINX] proxy_cache_use_stale updating and X-Accel-Expires=0
mdounin at mdounin.ru
Sat Jul 31 01:50:24 MSD 2010
On Wed, Jul 21, 2010 at 11:06:26AM +0200, Jérôme Loyet wrote:
> I have a strange situation. I don't really know if it's a bug or a feature.
> I'm using nginx as a cached reverse proxy to apache/mod_php.
> I have the following (simplified) conf:
> proxy_cache_use_stale updating error timeout invalid_header http_500
> http_502 http_503 http_504;
> Some pages returns the X-Accel-Expires=0 header to exclude a page from
> the cache. It works great. But sometimes, nginx returns those page
> with a 404 response without fetching the page to the backend server.
> Those pages are marked as UPDATING in logs.
Directive proxy_cache_use_stale set to "updating" instructs nginx
to return stale cached response if one request to the same uri
is already goes to backend.
> How a page excluded from the cache can be wrongly (404 instead of 200)
> served by the cache with an UPDATING status ?
Looks like you happen to have stale document with 404 status in
cache (e.g. cached during debugging). It's not expunged from
cache as it's active (i.e. frequently requested), and not updated
in cache as you return X-Accel-Expires=0 in responses.
But it's in cache, and once you get more than one simulteneous
request to this document - nginx returns stale response from cache
as it was said to.
More information about the nginx