From e4e9994ac67d9b051f25b7bb2899c05980d13aca Mon Sep 17 00:00:00 2001 From: Noste <83548733+Noooste@users.noreply.github.com> Date: Mon, 17 Aug 2026 12:02:22 +0200 Subject: [PATCH] fix(backend): improve cache control headers for static file serving Signed-off-by: Noste <83548733+Noooste@users.noreply.github.com> --- backend/internal/routes/routes.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/backend/internal/routes/routes.go b/backend/internal/routes/routes.go index e6664d1..7d0c438 100644 --- a/backend/internal/routes/routes.go +++ b/backend/internal/routes/routes.go @@ -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) })