diff --git a/server.go b/server.go index c6ead5d..56c41da 100644 --- a/server.go +++ b/server.go @@ -75,12 +75,16 @@ func (s *Server) registerRoutes() { s.mux.Handle("/", http.FileServer(http.FS(publicFS))) } -// middleware wraps handlers with CORS and logging. +// middleware wraps handlers with CORS, no-cache, and logging. func (s *Server) middleware(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Access-Control-Allow-Origin", "*") w.Header().Set("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS") w.Header().Set("Access-Control-Allow-Headers", "Content-Type") + // Prevent caching of static files during development. + w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate") + w.Header().Set("Pragma", "no-cache") + w.Header().Set("Expires", "0") if r.Method == "OPTIONS" { w.WriteHeader(http.StatusOK)