forked from tangled.org/core
this repo has no description

minor improvements to speed up page load

and trims timeline to 50 events now

Changed files
+16 -1
appview
+5
appview/db/timeline.go
···
})
}
+
// Limit the slice to 100 events
+
if len(events) > 50 {
+
events = events[:50]
+
}
+
sort.Slice(events, func(i, j int) bool {
return events[i].EventAt.After(events[j].EventAt)
})
+11 -1
appview/pages/pages.go
···
if err != nil {
log.Fatalf("no static dir found? that's crazy: %v", err)
}
-
return http.StripPrefix("/static/", http.FileServer(http.FS(sub)))
+
// Custom handler to apply Cache-Control headers for font files
+
return Cache(http.StripPrefix("/static/", http.FileServer(http.FS(sub))))
+
}
+
+
func Cache(h http.Handler) http.Handler {
+
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+
if strings.HasPrefix(r.URL.Path, "/static/fonts") {
+
w.Header().Set("Cache-Control", "public, max-age=31536000, immutable")
+
}
+
h.ServeHTTP(w, r)
+
})
}
func (p *Pages) Error500(w io.Writer) error {