Browser cache is too aggressive
Summary
After deploying a new frontigrade release with changes to JS/CSS assets, browsers sometimes use old cached assets, requiring the end user to hard-reload the page to get updated assets.
Steps to Reproduce
- view the app in Firefox
- make some changes to assets
- deploy a new version
- view the app again by loading the root url, not hard-reloading it
Expected Result
- new assets load
Actual Result
- old cached assets load
Additional context
It looks like the root /
document being served is what's being cached too aggressively. After recently deploying frontigrade 0.1.12 to production, I loaded www.cloudigra.de in my browser and observed old assets. I checked the network inspector to confirm that I was getting browser-cached data:
Loading the same url in private/incognito mode without any cache loaded the expected content:
Headers from the server for the root document:
$ http -h https://www.cloudigra.de/
HTTP/1.1 200 OK
Accept-Ranges: bytes
Cache-control: private
Content-Length: 1833
Content-Type: text/html
Date: Wed, 06 Feb 2019 19:07:44 GMT
ETag: "5c59bb11-729"
Last-Modified: Tue, 05 Feb 2019 16:34:25 GMT
Server: nginx/1.14.2
Set-Cookie: d8773944d447c230a2af881fd01d1ddf=43dc036e2dfbb937a62ab0102a536cf0; path=/; HttpOnly; Secure
See also:
- https://stackoverflow.com/a/49637255
- https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9.1
private
Indicates that all or part of the response message is intended for a single user and MUST NOT be cached by a shared cache. This allows an origin server to state that the specified parts of the response are intended for only one user and are not a valid response for requests by other users. A private (non-shared) cache MAY cache the response.