diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-23 21:35:52 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-23 21:35:52 +0200 |
| commit | bfa8df7b36ccbd44703e0705d51a2ed553a23164 (patch) | |
| tree | 5b760ff95f6e9498dec77f813eddd5538c0b1177 /internal/web/server.go | |
| parent | ba3c501ec516e1cc58870708a83874b10fc4584a (diff) | |
| download | lectio-bfa8df7b36ccbd44703e0705d51a2ed553a23164.tar.gz lectio-bfa8df7b36ccbd44703e0705d51a2ed553a23164.zip | |
web: no-store responses + robust theme-link swap (fixes stale-cache 'theme switch stopped working')
Diffstat (limited to 'internal/web/server.go')
| -rw-r--r-- | internal/web/server.go | 12 |
1 files changed, 11 insertions, 1 deletions
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 |
