Add caching middlware for static files

This commit is contained in:
2025-01-14 13:43:16 +01:00
parent 82aa5ef57d
commit 13c2693bdb
2 changed files with 10 additions and 1 deletions

View File

@ -29,3 +29,10 @@ func (app *application) logRequest(next http.Handler) http.Handler {
next.ServeHTTP(w, r)
})
}
func (app *application) cacheStatic(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Cache-Control", "public, max-age=86400")
next.ServeHTTP(w, r)
})
}