From b9bb8629a8a13d1367fa7e26894ed48d6de6bf2e Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Sun, 16 Aug 2026 13:52:55 -0700 Subject: [PATCH] Cache fonts and brand assets for a day --- main.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index e33a823..353df7f 100644 --- a/main.go +++ b/main.go @@ -58,9 +58,13 @@ func (staticFiles) Has(key string) bool { return err == nil } -func noCache(next http.Handler) http.Handler { +func cacheControl(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Cache-Control", "no-cache") + if strings.HasPrefix(r.URL.Path, "/static/fonts/") || strings.HasPrefix(r.URL.Path, "/static/brand/") { + w.Header().Set("Cache-Control", "public, max-age=86400") + } else { + w.Header().Set("Cache-Control", "no-cache") + } next.ServeHTTP(w, r) }) } @@ -133,5 +137,5 @@ func main() { port = "8080" } log.Printf("listening on http://localhost:%s", port) - log.Fatal(http.ListenAndServe(":"+port, noCache(handler))) + log.Fatal(http.ListenAndServe(":"+port, cacheControl(handler))) }