Our CSS and JS files are not being re-downloaded by web browsers when we update them.
The response headers look like this:
cache-control: max-age=7776000
content-encoding: gzip
content-type: text/css; charset=UTF-8
date: Sat, 01 Feb 2020 02:41:59 GMT
etag: W/"5e34c19d-68a08"
expires: Fri, 01 May 2020 02:41:59 GMT
last-modified: Sat, 01 Feb 2020 00:09:01 GMT
server: nginx/1.16.1
status: 200
vary: Accept-Encoding
We want web browsers to cache them for 3 months, but we want them to expire the cache prematurely if the files have been modified. Shouldn't the ETag modify itself when the files are updated, and therefore when the Etag is different from the one already in the cache, redownload the file? Am I misunderstanding how it works?
We are sending a last-modified timestamp but web browsers aren't re-downloading even though the file stored in the cache is from before the last modified date? Is there a header we are missing in order to get the desired behavior?
I'm trying to avoid tacking on a cache buster query string such as file.css?v=2