I am using the
Cache-Control header to implement client-side caching. Since I update my website only once a month I would like the
JS files to be cached for 30 days with
Cache-Control: max-age=2592000. The problem is that the 30-day period defined by
Cache-Control doesn't coincide with the website update cycle, it starts from the moment the users visit the site and ends 30 days later, which means an update could occur in the meantime and users would be running with outdated content for a while, which could break the rendering of the website if for instance the
CSS no longer match.
How can I perform client-side caching of content for periods of several days but somehow get users to refresh their
CSS/JS files after the website has been updated?
One solution I could think of is that if website updates can be schedule, the
max-age returned by the server could be decreased every day accordingly so that no matter when people visit the website, the end of caching period would coincide with the update of the website, but changing the server configuration every day goes against one of my sysadmin principles (once it's running, don't touch it).