Add Cache-Control header for static file serving

This commit is contained in:
2025-05-27 17:37:54 +08:00
parent 87a9fdeb9b
commit 7bcae71495

View File

@@ -33,6 +33,7 @@ func FrontendMiddleware(c fiber.Ctx) error {
if _, err := os.Stat(file); path == "/" || os.IsNotExist(err) { if _, err := os.Stat(file); path == "/" || os.IsNotExist(err) {
return serveIndexHtml(c) return serveIndexHtml(c)
} else { } else {
c.Set("Cache-Control", "public, max-age=31536000, immutable")
return c.SendFile(file) return c.SendFile(file)
} }
} }