+5
appview/db/timeline.go
+5
appview/db/timeline.go
+11
-1
appview/pages/pages.go
+11
-1
appview/pages/pages.go
···
415
415
if err != nil {
416
416
log.Fatalf("no static dir found? that's crazy: %v", err)
417
417
}
418
-
return http.StripPrefix("/static/", http.FileServer(http.FS(sub)))
418
+
// Custom handler to apply Cache-Control headers for font files
419
+
return Cache(http.StripPrefix("/static/", http.FileServer(http.FS(sub))))
420
+
}
421
+
422
+
func Cache(h http.Handler) http.Handler {
423
+
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
424
+
if strings.HasPrefix(r.URL.Path, "/static/fonts") {
425
+
w.Header().Set("Cache-Control", "public, max-age=31536000, immutable")
426
+
}
427
+
h.ServeHTTP(w, r)
428
+
})
419
429
}
420
430
421
431
func (p *Pages) Error500(w io.Writer) error {