Skip to content

Commit

Permalink
Set cache-control header non-cache for assets not found
Browse files Browse the repository at this point in the history
Signed-off-by: Scott Windsor <[email protected]>
  • Loading branch information
sentientmonkey committed Sep 2, 2023
1 parent 01e0727 commit 6336fde
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1218,7 +1218,11 @@ func (server *ArgoCDServer) newStaticAssetsHandler() func(http.ResponseWriter, *
http.ServeContent(w, r, "index.html", modTime, io.NewByteReadSeeker(data))
} else {
if isMainJsBundle(r.URL) {
w.Header().Set("Cache-Control", "public, max-age=31536000, immutable")
cacheControl := "public, max-age=31536000, immutable"
if !fileRequest {
cacheControl = "no-cache"
}
w.Header().Set("Cache-Control", cacheControl)
}
http.FileServer(server.staticAssets).ServeHTTP(w, r)
}
Expand Down
2 changes: 1 addition & 1 deletion server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1274,7 +1274,7 @@ func TestCacheControlHeaders(t *testing.T) {
filename: "main.e4188e5adc97bbfc00c0.js",
createFile: false,
expectedStatus: 404,
expectedCacheControlHeaders: []string{"public, max-age=31536000, immutable"},
expectedCacheControlHeaders: []string{"no-cache"},
},
}

Expand Down

0 comments on commit 6336fde

Please sign in to comment.