Closed Nuanda closed 8 years ago
How it is configured on production? It is the best to configure something like this in nginx:
location ~* ^/assets/ {
# Per RFC2616 - 1 year maximum expiry
expires 1y;
add_header Cache-Control public;
# Some browsers still send conditional-GET requests if there's a
# Last-Modified header or an ETag header even if they haven't
# reached the expiry date sent in the Expires header.
add_header Last-Modified "";
add_header ETag "";
break;
}
It's exactly like that, and also gzip is turned on.
Hmm, it appears the Last-Modified header confuses the process. When commented out, the 304 response is returned and the browser takes its internal,. cached version. I found it thanks to that minimal setting tutorial: http://vladigleba.com/blog/2014/03/27/deploying-rails-apps-part-4-configuring-nginx/
i don't think resetting Last-Modified to an empty string is important, as long as rails renames the assets after recompile, right?
Tested on Chromium, FF, Opera (all Linux) and Chrome (And 5.1.1 Nexus 7) and removing Last-Modified overwrite turns caching on. Yay, everybody rejoice.
This also works for plgapp, thx for hint :+1:
IE test, anyone? ;)
Tested in IE11.
Currently I think it does not work. For instance, when reloading the page, the app.js and app.css files are downloaded afresh (200 KB of data) instead of getting the 304 response. Same for the icons font file.