Issue #489 - Static assets are being browser cached between upgrades (#502)

This commit is contained in:
Alexander Matyushentsev 2018-08-08 21:10:40 +03:00 committed by GitHub
parent 7c8cc41d4c
commit cbf1e3419b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -63,6 +63,13 @@ var (
ErrNoSession = status.Errorf(codes.Unauthenticated, "no session information")
)
var noCacheHeaders = map[string]string{
"Expires": time.Unix(0, 0).Format(time.RFC1123),
"Cache-Control": "no-cache, private, max-age=0",
"Pragma": "no-cache",
"X-Accel-Expires": "0",
}
var backoff = wait.Backoff{
Steps: 5,
Duration: 500 * time.Millisecond,
@ -425,6 +432,9 @@ func (a *ArgoCDServer) newHTTPServer(ctx context.Context, port int) *http.Server
// serve index.html for non file requests to support HTML5 History API
if acceptHTML && !fileRequest && (request.Method == "GET" || request.Method == "HEAD") {
for k, v := range noCacheHeaders {
writer.Header().Set(k, v)
}
http.ServeFile(writer, request, a.StaticAssetsDir+"/index.html")
} else {
http.ServeFile(writer, request, a.StaticAssetsDir+request.URL.Path)