# Why is nginx caching this?

**URL:** <https://www.ruby-forum.com/t/why-is-nginx-caching-this/191514>\
**Category:** NGINX\
**Created:** [July 13, 2010, 6:51pm UTC](https://www.ruby-forum.com/t/why-is-nginx-caching-this/191514 "2010-07-13T18:51:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![adriannye](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e5b9ba/32.png) [@adriannye](https://www.ruby-forum.com/u/adriannye)\
**Post date:** [July 13, 2010, 6:51pm UTC](https://www.ruby-forum.com/t/why-is-nginx-caching-this/191514/1 "2010-07-13T18:51:59Z")

</div>

I can’t make nginx stop caching these files and need help.

This server has nginx as a frontend for django and apache. One of the  
directories /media/flash/data  
must NOT be cached since it is edited by django. I have set headers to  
turn caching off, and confirmed that this is making the browser not  
cache, but nginx is still caching it, even though the date of the file  
is newer than the Expires date and no-cache is set. In fact, I can  
even restart nginx and it still serves the old file after the restart.  
I can even delete the file in question from the server and it is still  
served (the old version). What do I put in this config file to make it  
read this file every time, or at least anytime it has been updated since  
the last time it was read from the same browser? Thanks.

server {  
listen (ip removed):443;  
ssl on;  
ssl\_certificate /etc/httpd/ssl/bundle-ups-mms-stg.t-3.com.crt;  
ssl\_certificate\_key /etc/httpd/ssl/ups-mms-stg.t-3.com.key;  
server\_name [ups-mms-stg.t-3.com](http://ups-mms-stg.t-3.com) [www.ups-mms-stg.t-3.com](http://www.ups-mms-stg.t-3.com);  
access\_log /www/nginx\_logs/nginx\_access.log;  
error\_log /www/nginx\_logs//nginx\_error.log;  
location / {  
proxy\_pass https://(ip removed):4443;  
include /etc/nginx/proxy.conf;  
}

location /media/ {  
root /www/ups-mms/trunk/www/;  
}

location /media/flash/data/ {  
root /www/ups-mms/branches/stable0.1/www/;  
add\_header Cache-Control “no-cache”;  
add\_header Last-Modified “”;  
add\_header Expires “Mon, 21 Sep 2009 04:52:34 GMT”;  
add\_header Pragma “no-cache”;  
}

location /static/ {  
root /www/ups-mms/trunk/www/;  
}

location /admin\_media/ {  
root /www/ups-mms/trunk/www/;  
}

location /bundles/ {  
root /www/ups-mms/trunk/www/;  
}

location /videos/ {  
root /www/ups-mms/trunk/www/;  
}

location /agencies/ {  
root /www/ups-mms/trunk/www/;  
}  
}

server {  
listen (ip removed):80;  
server\_name [ups-mms-stg.t-3.com](http://ups-mms-stg.t-3.com) [www.ups-mms-stg.t-3.com](http://www.ups-mms-stg.t-3.com);  
access\_log /www/nginx\_logs/nginx\_access.log;  
error\_log /www/nginx\_logs//nginx\_error.log;  
location / {  
proxy\_pass http://(ip removed):8080;  
include /etc/nginx/proxy.conf;  
}

location /media/ {  
root /www/ups-mms/trunk/www/;  
}

location /media/flash/data/ {  
root /www/ups-mms/branches/stable0.1/www/;  
add\_header Cache-Control “no-cache”;  
add\_header Last-Modified “”;  
add\_header Expires “Mon, 21 Sep 2009 04:52:34 GMT”;  
add\_header Pragma “no-cache”;  
}  
location /static/ {  
root /www/ups-mms/trunk/www/;  
}

location /admin\_media/ {  
root /www/ups-mms/trunk/www/;  
}

location /bundles/ {  
root /www/ups-mms/trunk/www/;  
}

}

Posted at Nginx Forum:

> **[why is nginx caching this?](https://forum.nginx.org/read.php?2,108336,108336#msg-108336)**
>
> I can't make nginx stop caching these files and need help. This server has nginx as a frontend for django and apache. One of the directories /media/flash/data must NOT be cached since it is edited by django. I have set headers to turn caching off,...

---

<div class="post-metadata">

**Author:** ![adriannye](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e5b9ba/32.png) [@adriannye](https://www.ruby-forum.com/u/adriannye)\
**Post date:** [July 13, 2010, 7:06pm UTC](https://www.ruby-forum.com/t/why-is-nginx-caching-this/191514/2 "2010-07-13T19:06:38Z")

</div>

Hi,

> I can’t make nginx stop caching these files and need help.

It’s not nginx - you don’t have caching enabled in your configuration  
(at  
least not in the part you pasted).

Best regards,  
Piotr S. \< [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) \>
