feat: better caching headers for images
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user