NoCache is a middleware function that adds headers that prevent proxies from caching responses.
(next http.Handler)
| 18 | |
| 19 | // NoCache is a middleware function that adds headers that prevent proxies from caching responses. |
| 20 | func NoCache(next http.Handler) http.Handler { |
| 21 | return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 22 | w.Header().Set("Cache-Control", "no-store") |
| 23 | w.Header().Set("Pragma", "no-cache") |
| 24 | next.ServeHTTP(w, r) |
| 25 | }) |
| 26 | } |