Disabled static http resources caching RIVM-30

This commit is contained in:
Mihail Slobodyanuk 2022-12-17 11:17:09 +02:00
parent 267a9109c6
commit 028539356c

View file

@ -397,7 +397,15 @@ func (a *AdminSocket) StartHttpServer(configFn string, nc *config.NodeConfig) {
}
}
if docFs == "" {
http.Handle("/", http.FileServer(http.Dir(nc.WwwRoot)))
var nocache = func(fs http.Handler) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
w.Header().Add("Cache-Control", "no-cache, no-store, must-revalidate")
w.Header().Add("Pragma", "no-cache")
w.Header().Add("Expires", "0")
fs.ServeHTTP(w, r)
}
}
http.Handle("/", nocache(http.FileServer(http.Dir(nc.WwwRoot))))
docFs = "local fs"
}
l, e := net.Listen("tcp4", u.Host)