My website uses .json
files to pre-fetch content across pages (similar to Gatsby). I noticed that there are caching problems with these files causing the content to be outdated across builds.
By digging further I discovered that the etag
is not changing between builds for json
files, even though it is changing as expected for other file formats like html and js. This can be seen by using these commands:
curl -I https://6075feb68aebef000702b864--idec.netlify.app
curl -I https://6075feb68aebef000702b864--idec.netlify.app/content.json
curl -I https://6075fddbc054a90007bc988e--idec.netlify.app
curl -I https://6075fddbc054a90007bc988e--idec.netlify.app/content.json
Notice that the etag change as expected on the root but does not change between the two /content.json
.
Also – for some reason the problem is more noticeable on Safari, Chrome is disregarding the etag and fetching the updated files. This is probably just a more agressive strategy on Chrome, the problem is still quite real for Safari users (and any other browser that would respect the etags properly).