feat: better caching headers for images

This commit is contained in:
2026-03-09 13:35:23 +01:00
parent a27b4a66e6
commit 2b07701762
11 changed files with 83 additions and 43 deletions
+3 -2
View File
@@ -6,6 +6,7 @@ import (
"net/http"
"time"
"git.schreifuchs.ch/schreifuchs/schreifuchs.ch/internal/pkg/middleware"
"git.schreifuchs.ch/schreifuchs/schreifuchs.ch/web"
)
@@ -14,7 +15,7 @@ func registerStatic(mux *http.ServeMux) {
fileSystem := web.GetStaticFS()
// we still use go's fileServer to avoid unnecessary implementation
fileServer := cacheMiddleware(time.Hour * 24)(http.FileServer(http.FS(fileSystem)))
fileServer := middleware.Cache(time.Hour * 24)(http.FileServer(http.FS(fileSystem)))
err := fs.WalkDir(fileSystem, ".", func(path string, d fs.DirEntry, err error) error {
if err != nil {
@@ -26,7 +27,7 @@ func registerStatic(mux *http.ServeMux) {
path = "/" + path
slog.Debug("registering file", "path", path)
slog.Debug("registered static file", "path", path)
mux.Handle(path, fileServer)