From bfa8df7b36ccbd44703e0705d51a2ed553a23164 Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Thu, 23 Jul 2026 21:35:52 +0200 Subject: web: no-store responses + robust theme-link swap (fixes stale-cache 'theme switch stopped working') --- internal/web/server.go | 12 +++++++++++- internal/web/templates/index.html | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'internal/web') diff --git a/internal/web/server.go b/internal/web/server.go index 50bf45d..10401ed 100644 --- a/internal/web/server.go +++ b/internal/web/server.go @@ -46,7 +46,17 @@ func NewServer(cfg config.Config) http.Handler { } mux.Handle("GET /static/", http.StripPrefix("/static/", http.FileServer(http.FS(staticSub)))) - return mux + return noStore(mux) +} + +// noStore stops the browser caching any lectio-web response, so a rebuilt or +// reinstalled server never has an old page, base.css or theme.css served from +// cache (which presents as "switching themes stopped working" after an update). +func noStore(h http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Cache-Control", "no-store") + h.ServeHTTP(w, r) + }) } // today is lectio-web's "no ?date=" default, in the YYYY-MM-DD form every diff --git a/internal/web/templates/index.html b/internal/web/templates/index.html index cc56a09..a1247e6 100644 --- a/internal/web/templates/index.html +++ b/internal/web/templates/index.html @@ -61,7 +61,7 @@