# Proxy-cache serving expired content

**URL:** <https://www.ruby-forum.com/t/proxy-cache-serving-expired-content/204812>\
**Category:** NGINX\
**Created:** [March 22, 2011, 10:01am UTC](https://www.ruby-forum.com/t/proxy-cache-serving-expired-content/204812 "2011-03-22T10:01:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [March 22, 2011, 10:01am UTC](https://www.ruby-forum.com/t/proxy-cache-serving-expired-content/204812/1 "2011-03-22T10:01:23Z")

</div>

Hello list,

we are using nginx as proxy/loadbalancer and cache in front of our  
serverpark consisting of 8 apache/php-servers.  
We are serving an average of 200 requests per second.

Performance and flexibility is second to none, however we are facing a  
problem which we really need to solve:

We are experiencing a bug which should have been fixed in 0.8.14:

> \*) Bugfix: an expired cached response might stick in the “UPDATING”  
> state.

Symptoms are: Files way beyond their expire time are still being served,  
the logs state “UPDATING”.  
Restarting nginx and therefore triggering the “cache loader” process  
leads to a cleanup of the stale file.  
This workaround however is no option for production since we have cache  
times of as little as 1 min and we obviously can not restart nginx every  
minute.

I know there has been some work done in ngx\_http\_file\_cache.c  
(c-\>node-\>updating, etc.) however there still seems to be some race. I  
would be more than willing to help given some pointers…

Since I have not found anything about this issue somewhere in the web  
recently and we seem to be the only ones experiencing this, I meanwhile  
even tend to think it is caused by our configuration (attached).

Any Help much appreciated, since we really want to stick with nginx (our  
customer does not in the meantime).

Thanks,  
Frank

* * *

## Config (somewhat shortened and anonymised):

worker\_processes 4;  
worker\_rlimit\_nofile 10240;  
working\_directory /var/lib/nginx/cores/;  
worker\_rlimit\_core 500M;  
error\_log /var/log/nginx/error.log warn;  
pid /var/run/nginx.pid;  
events {  
worker\_connections 8192;  
}  
http {  
server\_tokens off;  
include mime.types;  
default\_type application/octet-stream;  
log\_format main '$remote\_addr - $remote\_user [$time\_local]  
“$request” ’  
'$status $body\_bytes\_sent  
“$http\_referer” ’  
‘“$http\_user\_agent”  
“$http\_x\_forwarded\_for”’;  
access\_log /var/log/nginx/access.log main;  
sendfile on;  
keepalive\_timeout 65;  
gzip on;  
proxy\_cache\_path /var/ramdisk/nginx/abc levels=1:2:1  
keys\_zone=abc:1022m  
inactive=60m max\_size=5500m;  
proxy\_cache\_valid 200 45m;  
proxy\_cache\_valid 302 301 303 10m;  
proxy\_cache\_valid 404 10m;  
proxy\_cache\_valid any 10m;  
proxy\_cache\_valid 401 1s;  
proxy\_cache\_use\_stale updating error timeout invalid\_header;  
proxy\_cache\_key $scheme$host$uri$is\_args$args;  
proxy\_temp\_path /var/cache/nginx/tmp\_nginx;  
upstream abc\_pool {  
server 62.146.96.41 weight=3;  
server 62.146.96.44 weight=3;  
server 62.146.96.45 weight=3;  
server 62.146.96.46 weight=3;  
server 62.146.96.47 weight=3;  
server 62.146.96.48 weight=1;  
server 62.146.96.49 weight=3;  
server 62.146.96.53 weight=1;  
}  
server {  
include ports.conf;  
server\_name abcdefg;  
ssi on;  
proxy\_ignore\_client\_abort on;  
location / {  
gzip on;  
gzip\_types text/css application/x-javascript;  
proxy\_buffering on;  
proxy\_buffer\_size 8k;  
proxy\_pass http://abc\_pool;  
proxy\_set\_header Host $host;  
proxy\_set\_header X-Real-IP $remote\_addr;  
proxy\_set\_header X-Forwarded-For  
$proxy\_add\_x\_forwarded\_for;  
proxy\_cache abc;  
proxy\_cache\_valid 200 30m;  
proxy\_cache\_valid any 0m;  
proxy\_cache\_use\_stale error timeout invalid\_header  
updating;  
proxy\_cache\_key $scheme$host$uri$is\_args$args;  
proxy\_hide\_header Set-Cookie;  
proxy\_hide\_header Cookie;  
if ($args ~ module=) {  
rewrite ^(.\*)$ /modulerw/$1 last;  
}  
}  
location ~ (^/ajax/|^/community/|^/forum/|^/newsletter/) {  
proxy\_ignore\_client\_abort on;  
gzip on;  
gzip\_types text/css application/x-javascript;  
proxy\_buffering off;  
proxy\_buffer\_size 8k;  
proxy\_pass http://ip\_hash\_pool;  
proxy\_set\_header Host $host;  
proxy\_pass\_header Set-Cookie;  
proxy\_pass\_header Cookie;  
}  
location /css/ {  
gzip on;  
gzip\_types text/css;  
expires 3600;  
root /home/abc/trunk/public;  
}  
}

* * *

Posted at Nginx Forum:

> **[Proxy-cache serving expired content](https://forum.nginx.org/read.php?2,184782,184782#msg-184782)**
>
> Hello list, we are using nginx as proxy/loadbalancer and cache in front of our serverpark consisting of 8 apache/php-servers. We are serving an average of 200 requests per second. Performance and flexibility is second to none, however we are facing a...

---

<div class="post-metadata">

**Author:** ![frank\_r](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9de053/32.png) [@frank\_r](https://www.ruby-forum.com/u/frank_r)\
**Post date:** [June 22, 2011, 1:59pm UTC](https://www.ruby-forum.com/t/proxy-cache-serving-expired-content/204812/2 "2011-06-22T13:59:49Z")

</div>

For the records:

This seems to be fixed in 1.0.4.

Thanks alot!!!

Grüße,  
Frank

Posted at Nginx Forum:

> **[Re: Proxy-cache serving expired content](https://forum.nginx.org/read.php?2,184782,208999#msg-208999)**
>
> Hello list, we are using nginx as proxy/loadbalancer and cache in front of our serverpark consisting of 8 apache/php-servers. We are serving an average of 200 requests per second. Performance and flexibility is second to none, however we are facing a...
