fix(server): reduce static asset cache to prevent stale files after redeploy

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 <noreply@anthropic.com>
pull/5203/head
Steven 1 week ago
parent 2197178dd7
commit 91a7e927a5

@ -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
}

Loading…
Cancel
Save