From 872ae5db32c605ef385588a33673ce5fef29ff21 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Mon, 3 Jun 2024 22:24:39 +0200 Subject: feat: use stale-while-revalidate instead of immutable asset paths --- internal/server/mux.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'internal') diff --git a/internal/server/mux.go b/internal/server/mux.go index 1140484..7bddbe5 100644 --- a/internal/server/mux.go +++ b/internal/server/mux.go @@ -261,15 +261,15 @@ func NewMux( mux.HandleFunc("/packages/{source}/opensearch.xml", createOpenSearchXMLHandler(config.Packages)) mux.HandleFunc("/static/", func(w http.ResponseWriter, r *http.Request) { - // optimisation for HTTP/3: first header sent as byte(41), not the string - asset, found := frontend.Assets.ByImmutablePath[r.URL.Path] + asset, found := frontend.Assets.ByPath[r.URL.Path] if !found { http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound) return } - w.Header().Add("Cache-Control", "public, max-age=31536000") - w.Header().Add("Cache-Control", "immutable") + // optimisation for HTTP/3: first header sent as byte(41), not the string + w.Header().Add("Cache-Control", "public, max-age=86400") + w.Header().Add("Cache-Control", "stale-while-revalidate") http.ServeFileFS(w, r, frontend.Files, asset.Filename) }) -- cgit 1.4.1