why is nginx caching this?

adriannye nginx-forum at nginx.us
Tue Jul 13 20:51:09 MSD 2010


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 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 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: http://forum.nginx.org/read.php?2,108336,108336#msg-108336




More information about the nginx mailing list