about summary refs log tree commit diff stats
path: root/internal/server/mux.go
diff options
context:
space:
mode:
authorAlan Pearce2024-06-03 22:24:39 +0200
committerAlan Pearce2024-06-03 22:24:39 +0200
commit872ae5db32c605ef385588a33673ce5fef29ff21 (patch)
treec454f8d32cd4554c4780a50bb43ae7e9f82688cd /internal/server/mux.go
parent896926a63a8f2d145467b325f9b0198315e0af6d (diff)
downloadsearchix-872ae5db32c605ef385588a33673ce5fef29ff21.tar.lz
searchix-872ae5db32c605ef385588a33673ce5fef29ff21.tar.zst
searchix-872ae5db32c605ef385588a33673ce5fef29ff21.zip
feat: use stale-while-revalidate instead of immutable asset paths
Diffstat (limited to 'internal/server/mux.go')
-rw-r--r--internal/server/mux.go8
1 files changed, 4 insertions, 4 deletions
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)
 	})