fix: added cache on static files

This commit is contained in:
Florian Sylvain
2024-05-22 14:14:04 +02:00
parent ed5d52a506
commit adcd6fc08a
+1
View File
@@ -81,6 +81,7 @@ func StaticFileServerWithContentType(fsys http.FileSystem) http.Handler {
path := r.URL.Path path := r.URL.Path
if ext := filepath.Ext(path); ext != "" { if ext := filepath.Ext(path); ext != "" {
if ct, ok := contentTypes[ext]; ok { if ct, ok := contentTypes[ext]; ok {
w.Header().Set("Cache-Control", "public, max-age=31536000")
w.Header().Set("Content-Type", ct) w.Header().Set("Content-Type", ct)
} }
} }