# Nginx serving old files from cache

**URL:** <https://www.ruby-forum.com/t/nginx-serving-old-files-from-cache/218992>\
**Category:** NGINX\
**Created:** [April 18, 2012, 12:10pm UTC](https://www.ruby-forum.com/t/nginx-serving-old-files-from-cache/218992 "2012-04-18T12:10:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gurdipe\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b77776/32.png) [@Gurdipe\_D](https://www.ruby-forum.com/u/Gurdipe_D)\
**Post date:** [April 18, 2012, 12:10pm UTC](https://www.ruby-forum.com/t/nginx-serving-old-files-from-cache/218992/1 "2012-04-18T12:10:15Z")

</div>

I have nginx set as reverse proxy for Apache and for serving static  
files.  
Everything works great, except in the last few weeks I noticed that  
sometimes nginx returns page from cache which is 3-4 hours old. I  
checked the timestamp of the cache file, and it is old.

This is part of the config file related to caching in nginx.conf:  
proxy\_cache off;  
proxy\_buffering on;  
proxy\_buffer\_size 8k;  
proxy\_buffers 100 8k;  
proxy\_cache\_path /var/www/cache levels=1:2 keys\_zone=my-cache:8m  
max\_size=1000m;  
proxy\_temp\_path /var/www/cache/tmp;  
proxy\_cache\_key “$host$request\_uri”;  
proxy\_ignore\_headers “Expires” “Cache-Control” “X-Accel-Expires”;

and this is for particulat vhost:  
proxy\_cache my-cache;  
proxy\_cache\_valid 200 404 1m; # \<----- should be valid  
for just one minute!  
proxy\_ignore\_headers Expires;  
proxy\_ignore\_headers Cache-Control;  
proxy\_ignore\_headers X-Accel-Expires;  
proxy\_ignore\_headers Set-Cookie;  
proxy\_hide\_header Set-Cookie;

Any ideas?

Posted at Nginx Forum:

> **[nginx serving old files from cache](https://forum.nginx.org/read.php?2,225467,225467#msg-225467)**
>
> I have nginx set as reverse proxy for Apache and for serving static files. Everything works great, except in the last few weeks I noticed that sometimes nginx returns page from cache which is 3-4 hours old. I checked the timestamp of the cache file,...

---

<div class="post-metadata">

**Author:** ![VRider](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/87869e/32.png) [@VRider](https://www.ruby-forum.com/u/VRider)\
**Post date:** [April 18, 2012, 4:02pm UTC](https://www.ruby-forum.com/t/nginx-serving-old-files-from-cache/218992/2 "2012-04-18T16:02:41Z")

</div>

Do you have proxy\_cache\_use\_stale set? Has any nginx process  
segfaulted?

---

<div class="post-metadata">

**Author:** ![VRider](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/87869e/32.png) [@VRider](https://www.ruby-forum.com/u/VRider)\
**Post date:** [April 18, 2012, 4:51pm UTC](https://www.ruby-forum.com/t/nginx-serving-old-files-from-cache/218992/3 "2012-04-18T16:51:10Z")

</div>

No segfaults and proxy\_cache\_use\_stale wasn’t specified, so by default  
it was off.

D

Posted at Nginx Forum:

> **[Re: nginx serving old files from cache](https://forum.nginx.org/read.php?2,225467,225482#msg-225482)**
>
> I have nginx set as reverse proxy for Apache and for serving static files. Everything works great, except in the last few weeks I noticed that sometimes nginx returns page from cache which is 3-4 hours old. I checked the timestamp of the cache file,...
