I have a cache invalidation system in place, so I need to set the cache for css|js to never expire.
I tried this
location ~* \.(js|css)$ { # |png|jpg|jpeg|gif|ico
expires max;
#log_not_found off; # what's this for?
}
And this is what I see in firebug:
So as you can see, requests are still being made, though they only receive a 'not modified' response. But I want to avoid them entirely, is that possible?
Also, I've read that an expirires of more than 1 year is or will be considered invalid in the standard. Is that true?
Edit
Let me complete @DisgruntledGoat's answer:
- Normal access to the url, like clicking on a link or in the url bar + enter: cache works, only 1 request issued for that url, and 0 for the assets.
- F5 to reload: many requests issued, but you receive all '304 not modified' responses for the assets, so they are not downloaded
- ctrl + F5 to reload without cache: many requests, all '200 success', all the assets are downloaded again.
Best Answer
Are you reloading the page to test this? When you do that, browsers generally request every file again (at least Chrome does). If you instead click links to different pages on your site, the browser should just use the cache and not re-request files.
Additionally, according to the spec the
Expires
directive can only have a date up one year in the future, so 2037 is an invalid value. Having said that, browsers generally accept far-future values just fine.