Created
August 20, 2019 08:15
-
-
Save a-h/c0d85863621a67e980f7fad44e645fbc to your computer and use it in GitHub Desktop.
Disable caching and sniffing via HTTP headers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func DisableCachingAndSniffing(next http.Handler) http.Handler { | |
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | |
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate;") | |
w.Header().Set("pragma", "no-cache") | |
w.Header().Set("X-Content-Type-Options", "nosniff") | |
next.ServeHTTP(w, r) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment