How to set cache to never expire and minimize requests in Nginx?
Solution 1:
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.
Solution 2:
This cannot be done in another way you try it. It depends on the clients browser how cache is handled. Setting cache should not exceed one year more than the modification date Source.
Nginx is very effective, if you have < 1,000,000 visitors every day, you really don't have to worry about requests sent to Nginx. If it is about bandwidth, if a browser gets a 304 responce, it still uses the data from its cache, so no bandwidth is spilled.