diff --git a/ABSTRACTS.webp b/ABSTRACTS.webp
new file mode 100644
index 0000000..185fe17
Binary files /dev/null and b/ABSTRACTS.webp differ
diff --git a/blog/templates/landing.html b/blog/templates/landing.html
index 35c40d4..92066f4 100644
--- a/blog/templates/landing.html
+++ b/blog/templates/landing.html
@@ -65,6 +65,6 @@
-
+
{{end}}
diff --git a/main.go b/main.go
index d2eac8a..ae31b71 100644
--- a/main.go
+++ b/main.go
@@ -33,11 +33,26 @@ func gzipHandler(next http.Handler) http.Handler {
})
}
+func cacheHandler(next http.Handler) http.Handler {
+ return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ if strings.HasPrefix(r.URL.Path, "/src/") ||
+ strings.HasPrefix(r.URL.Path, "/content/images/") ||
+ strings.HasPrefix(r.URL.Path, "/ABSTRACTS.") ||
+ strings.HasPrefix(r.URL.Path, "/blog/og/") {
+ w.Header().Set("Cache-Control", "public, max-age=31536000, immutable")
+ }
+ next.ServeHTTP(w, r)
+ })
+}
+
func main() {
mux := http.NewServeMux()
mux.HandleFunc("/ABSTRACTS.png", func(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, "ABSTRACTS.png")
})
+ mux.HandleFunc("/ABSTRACTS.webp", func(w http.ResponseWriter, r *http.Request) {
+ http.ServeFile(w, r, "ABSTRACTS.webp")
+ })
mux.Handle("/src/", http.StripPrefix("/src/", http.FileServer(http.Dir("src"))))
mux.Handle("/content/images/", http.StripPrefix("/content/images/", http.FileServer(http.Dir("content/images"))))
@@ -49,5 +64,5 @@ func main() {
mux.HandleFunc("/", blog.ServeLanding)
log.Println("listening on :8000")
- http.ListenAndServe(":8000", gzipHandler(mux))
+ http.ListenAndServe(":8000", cacheHandler(gzipHandler(mux)))
}