CSS and JS files not being updated, supposedly because of Nginx Caching
Posted
by
Alberto Elias
on Server Fault
See other posts from Server Fault
or by Alberto Elias
Published on 2012-11-12T16:25:04Z
Indexed on
2012/11/12
17:03 UTC
Read the original article
Hit count: 301
I have my web app working with AppCache and I would like that when I modify my html/css/js files, and then update my Cache Manifest, that when the user accesses my web app, they will have an updated version of those files. If I change an HTML file, it works perfectly, but when I change CSS and JS files, the old version is still being used.
I've been checking everything out and I think it's related to my nginx configuration. I have a cache.conf file that contains the following:
gzip on;
gzip_types text/css application/x-javascript text/x-component text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon;
location ~ \.(css|js|htc)$ {
expires 31536000s;
add_header Pragma "public";
add_header Cache-Control "max-age=31536000, public, must-revalidate, proxy-revalidate";
}
location ~ \.(html|htm|rtf|rtx|svg|svgz|txt|xsd|xsl|xml)$ {
expires 3600s;
add_header Pragma "public";
add_header Cache-Control "max-age=3600, public, must-revalidate, proxy-revalidate";
}
And in default.conf I have my locations. I would like to have this caching working on all locations except one, how could I configure this? I've tried the following and it isn't working:
location /dir1/dir2/ {
root /var/www/dir1;
add_header Pragma "no-cache";
add_header Cache-Control "private";
expires off;
}
Thanks
© Server Fault or respective owner