Skip to content

Commit

Permalink
Issue argoproj#489 - Static assets are being browser cached between u…
Browse files Browse the repository at this point in the history
…pgrades (argoproj#502)
  • Loading branch information
alexmt authored Aug 8, 2018
1 parent 7c8cc41 commit cbf1e34
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit cbf1e34

Please sign in to comment.