all repos — searchix @ 872ae5db32c605ef385588a33673ce5fef29ff21

Search engine for NixOS, nix-darwin, home-manager and NUR users

feat: use stale-while-revalidate instead of immutable asset paths

Alan Pearce
commit

872ae5db32c605ef385588a33673ce5fef29ff21

parent

896926a63a8f2d145467b325f9b0198315e0af6d

1 file changed, 4 insertions(+), 4 deletions(-)

changed files
M internal/server/mux.gointernal/server/mux.go
@@ -261,15 +261,15 @@ mux.HandleFunc("/options/{source}/opensearch.xml", createOpenSearchXMLHandler(config.Options))
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) })