Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

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

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