cache media

master
Bel LaPointe 2024-09-19 13:54:02 -04:00
parent 9bda977a29
commit 03565e4fbc
1 changed files with 2 additions and 0 deletions

View File

@ -50,6 +50,8 @@ func Run(ctx context.Context, args []string) error {
Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if strings.HasPrefix(r.URL.Path, "/media/") {
http.StripPrefix("/media/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Cache-Control", "private, max-age=31536000")
w.Header().Add("Cache-Control", "immutable")
http.FileServer(http.Dir(*d)).ServeHTTP(w, r)
})).ServeHTTP(w, r)
return