httpd: allow to configure cache control header

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino
2024-08-12 21:52:59 +02:00
parent 2cc2fc64db
commit 6f8bc59756
8 changed files with 40 additions and 3 deletions

View File

@@ -586,3 +586,17 @@ func checkPartialAuth(w http.ResponseWriter, r *http.Request, audience string, t
}
return nil
}
func cacheControlMiddleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Cache-Control", "no-cache, no-store, max-age=0, must-revalidate, private")
next.ServeHTTP(w, r)
})
}
func cleanCacheControlMiddleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Del("Cache-Control")
next.ServeHTTP(w, r)
})
}