Files
spend-sparrow/handler/middleware/cache_control.go
Tim Wundenberg 128a2fc4d7
All checks were successful
Build Docker Image / Build-Docker-Image (push) Successful in 5m22s
Build and Push Docker Image / Build-And-Push-Docker-Image (push) Successful in 5m26s
fix: lint errors
2025-05-26 08:39:32 +02:00

19 lines
366 B
Go

package middleware
import (
"net/http"
"strings"
)
func CacheControl(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
shouldCache := strings.HasPrefix(r.URL.Path, "/static")
if !shouldCache {
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
}
next.ServeHTTP(w, r)
})
}