examples: tell browsers to not cache wasm files from the example server

This commit is contained in:
Justin Clift
2019-05-02 21:31:42 +10:00
committed by Johan Brandhorst
parent 99da328453
commit d594342642
2 changed files with 46 additions and 15 deletions
+5
View File
@@ -12,6 +12,11 @@ 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")
}