Optize font performance

This commit is contained in:
2026-04-18 07:56:14 +02:00
parent c85ea3bb0c
commit eee79b34bb
3 changed files with 11 additions and 1 deletions
+7 -1
View File
@@ -54,7 +54,13 @@ func main() {
h := &handler{root: root, user: *user, pass: *pass}
staticFS, _ := fs.Sub(assets, "assets")
http.Handle("/_/", http.StripPrefix("/_/", http.FileServer(http.FS(staticFS))))
static := http.StripPrefix("/_/", http.FileServer(http.FS(staticFS)))
http.Handle("/_/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if strings.HasPrefix(r.URL.Path, "/_/fonts/") {
w.Header().Set("Cache-Control", "public, max-age=31536000, immutable")
}
static.ServeHTTP(w, r)
}))
http.Handle("/", h)
log.Printf("datascape listening on %s, wiki at %s", *addr, root)