package util import ( "net/http" "time" ) var epoch = time.Unix(0, 0).Format(time.RFC1123) var noCacheHeaders = map[string]string{ "Expires": epoch, "Cache-Control": "no-cache, private, max-age=0", "Pragma": "no-cache", "X-Accel-Expires": "0", } // NoCache writes nocache headers func NoCache(h http.Handler) http.HandlerFunc { fn := func(w http.ResponseWriter, r *http.Request) { // Set our NoCache headers for k, v := range noCacheHeaders { w.Header().Set(k, v) } h.ServeHTTP(w, r) } return fn }