From 91a7e927a5c2c92fa11a42045ec4a4b9019afec2 Mon Sep 17 00:00:00 2001 From: Steven Date: Tue, 28 Oct 2025 07:55:02 +0800 Subject: [PATCH] fix(server): reduce static asset cache to prevent stale files after redeploy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changed Cache-Control max-age from 7 days to 1 hour with immutable directive. This prevents users from experiencing blank pages or JS errors when accessing frequently redeployed instances (e.g., demo environments) where old cached assets may reference files that no longer exist after redeployment. Since Vite generates content-hashed filenames, the immutable directive prevents unnecessary revalidation while the shorter cache duration ensures fresh assets are served within an hour of redeployment. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- server/router/frontend/frontend.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server/router/frontend/frontend.go b/server/router/frontend/frontend.go index f3eccd996..bb60f96ec 100644 --- a/server/router/frontend/frontend.go +++ b/server/router/frontend/frontend.go @@ -39,8 +39,12 @@ func (*FrontendService) Serve(_ context.Context, e *echo.Echo) { if c.Path() == "/" || c.Path() == "/index.html" { return false } - // Set Cache-Control header to allow public caching with a max-age of 7 days. - c.Response().Header().Set(echo.HeaderCacheControl, "public, max-age=604800") // 7 days + // Set Cache-Control header for static assets. + // Since Vite generates content-hashed filenames (e.g., index-BtVjejZf.js), + // we can cache aggressively but use immutable to prevent revalidation checks. + // For frequently redeployed instances, use shorter max-age (1 hour) to avoid + // serving stale assets after redeployment. + c.Response().Header().Set(echo.HeaderCacheControl, "public, max-age=3600, immutable") // 1 hour return false }