diff --git a/assets/page.html b/assets/page.html index 0da172f..4d550da 100644 --- a/assets/page.html +++ b/assets/page.html @@ -5,6 +5,8 @@ {{.Title}} + + diff --git a/assets/style.css b/assets/style.css index c5dd903..a7fae4b 100644 --- a/assets/style.css +++ b/assets/style.css @@ -2,10 +2,12 @@ @font-face { font-family: "Iosevka Etoile"; src: url("/_/fonts/IosevkaEtoile.woff2") format("woff2"); + font-display: swap; } @font-face { font-family: "Iosevka Slab"; src: url("/_/fonts/IosevkaSlab.woff2") format("woff2"); + font-display: swap; } /* === Theme === */ diff --git a/main.go b/main.go index 50c624f..ef0f33c 100644 --- a/main.go +++ b/main.go @@ -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)