[NGINX] proxy_cache_use_stale updating and X-Accel-Expires=0

Jérôme Loyet jerome at loyet.net
Wed Jul 21 13:29:06 MSD 2010


Le 21 juillet 2010 11:06, Jérôme Loyet <jerome at loyet.net> a écrit :
> Hi,
>
> 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;
> proxy_cache_key $scheme$host$request_uri$args;
> proxy_cache_path /CACHE levels=1:2:2 keys_zone=cache:256m inactive=1d
> max_size=20g;
> proxy_no_cache $http_authorization;
> proxy_ignore_headers Expires Cache-Control;
>
> upstream backend.www {
>    server www0:9001;
>    server www1:9001;
>    server www2:9001;
>    server www3:9001;
>    server www4:9001;
>    server www5:9001;
>    server www6:9001;
>    server www7:9001;
>    server www8:9001;
>    server www9:9001;
>  }
>
> server {
>  listen 80;
>  location / {
>    proxy_cache_valid 200 301 302 404 500 5m;
>    proxy_cache_valid any 1m;
>    proxy_pass http://backend.www;
>  }
> }
>
> 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.
>
> How a page excluded from the cache can be wrongly (404 instead of 200)
> served by the cache with an UPDATING status ?
>
> Here are extracts of my logs.
>
>
> XXXXXX - - [16/Jul/2010:11:18:36 +0200] "GET
> /index_favoris.php?cid=52440 HTTP/1.1" 200 1403
> "http://www.foo.bar/cid52440/" "" "4.74" 0.099 X-Accel-Expires=0
> 10.26.49.22:9004,200,0.099,MISS <-- it works
>
> XXXXXX - - [16/Jul/2010:11:24:55 +0200] "GET
> /index_favoris.php?cid=52440 HTTP/1.0" 404 3076
> "http://www.foo.bar/cid52440/" "" "-" 0.000 X-Accel-Expires=-
> -,-,-,UPDATING <-- doesn't work
>
> XXXXXX - - [16/Jul/2010:11:32:15 +0200] "GET
> /index_favoris.php?cid=52440 HTTP/1.0" 404 3076
> "http://www.foo.bar/cid52440/" "" "-" 0.000 X-Accel-Expires=-
> -,-,-,UPDATING <-- doesn't work
>
> Thx for your replies

btw I forgot to specified the nginx version I'm using: 0.8.41

>
> ++ Jerome
>



More information about the nginx mailing list