mirror of https://github.com/linkerd/linkerd2.git
Ensure cache does not store index_bundle.js (#3891)
## Motivation Full background: #2074 #2074 was recently reopened because a user reported an error that occurs when refreshing an already opened dashboard after the dashboard build has changed. This can occur when upgrading or downgrading. #2074 explores a larger issue about a redirection that occurs when loading the dashboard JS. However, the actual issue that users are experiencing happens because `index_bundle.js` is being cached when it should not be. Even if the hash of the JS bundle changes, users can see (on the current edge) that browsers do in fact cache `index_bundle.js`. The easiest way I reproduced this was: 1. Install `edge-19.12.3` 2. `linkerd dashboard` (and keep the tab open) 2. Uninstall `edge-19.12.3` 3. Install `stable-2.5.0` 4. `linkerd dashboard` 5. Refresh in all browsers: Users will observe the `edge-19.12.3` dashboard still renders (with all of it's new additions) even though `stable-2.5.0` is installed with it's older theme. Below are screenshots of Safari and Firefox caching the file. Chrome was not as easy to reproduce: *Safari*  *Firefox*  ## Solution This change only changes the response header when requesting `index_bundle.js` from the server to ensure caching does not take place; mainly `no-cache` is changed to `no-store` and `must-revalidate` is now included. `no-store` and `must-revalidate` are redundant on some browsers but both required to cover all browsers (and versions). Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
This commit is contained in:
parent
287900a686
commit
63c8c65ec7
|
@ -252,7 +252,7 @@ func mkStaticHandler(staticDir string) httprouter.Handle {
|
|||
filepath := p.ByName("filepath")
|
||||
if filepath == "/index_bundle.js" {
|
||||
// don't cache the bundle because it references a hashed js file
|
||||
w.Header().Set("Cache-Control", "no-cache, private, max-age=0")
|
||||
w.Header().Set("Cache-Control", "no-store, must-revalidate")
|
||||
}
|
||||
|
||||
req.URL.Path = filepath
|
||||
|
|
Loading…
Reference in New Issue