fix(backend): improve cache control headers for static file serving

Signed-off-by: Noste <83548733+Noooste@users.noreply.github.com>
This commit is contained in:
Noste
2026-08-17 12:02:22 +02:00
parent 367338af7c
commit e4e9994ac6
+6 -1
View File
@@ -355,10 +355,15 @@ func SetupRoutes(
// Try to serve static files first
filePath := filepath.Join(cfg.Server.FrontendPath, path)
if info, err := os.Stat(filePath); err == nil && !info.IsDir() {
if strings.HasPrefix(path, "/assets/") {
c.Set(fiber.HeaderCacheControl, "public, max-age=31536000, immutable")
} else {
c.Set(fiber.HeaderCacheControl, "no-cache")
}
return c.SendFile(filePath)
}
// If no static file exists, serve index.html for SPA routing
c.Set(fiber.HeaderCacheControl, "no-cache")
indexPath := filepath.Join(cfg.Server.FrontendPath, "index.html")
return c.SendFile(indexPath)
})