Files
spend-sparrow/internal/handler/middleware/cache_control.go
Tim Wundenberg 0c40680d76
Some checks failed
Build Docker Image / Build-Docker-Image (push) Has been cancelled
fix: move implementation to "internal" package
2025-05-29 13:39:26 +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)
})
}