example: just using 'Cache-Control': 'no-cache' should be good enough

This commit is contained in:
Justin Clift
2019-05-04 13:10:05 +10:00
committed by Ron Evans
parent 08ee1916f5
commit 4c8c048c49
2 changed files with 7 additions and 18 deletions
-5
View File
@@ -12,15 +12,10 @@ func main() {
fs := http.FileServer(http.Dir(dir))
log.Print("Serving " + dir + " on http://localhost:8080")
http.ListenAndServe(":8080", http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) {
resp.Header().Set("Cache-Control", "max-age=0")
resp.Header().Add("Cache-Control", "no-store")
resp.Header().Add("Cache-Control", "no-cache")
resp.Header().Add("Cache-Control", "must-revalidate")
resp.Header().Set("Expires", "Thu, 01 Jan 1970 00:00:00 GMT")
if strings.HasSuffix(req.URL.Path, ".wasm") {
resp.Header().Set("content-type", "application/wasm")
}
fs.ServeHTTP(resp, req)
}))
}