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.

chore: caching resource files accelerates second requests (#4614)

倒霉狐狸ebf13c4dffc9
diff --git a/server/router/frontend/frontend.go b/server/router/frontend/frontend.go
index 3920423b8..a3b499c2f 100644
--- a/server/router/frontend/frontend.go
+++ b/server/router/frontend/frontend.go
@@ -31,7 +31,12 @@ func NewFrontendService(profile *profile.Profile, store *store.Store) *FrontendS
func (*FrontendService) Serve(_ context.Context, e *echo.Echo) {
apiSkipper := func(c echo.Context) bool {
- return util.HasPrefixes(c.Path(), "/api", "/memos.api.v1")
+ if util.HasPrefixes(c.Path(), "/api", "/memos.api.v1") {
+ return true
+ }
+ // Set Cache-Control header to allow public caching with a max-age of 30 days (in seconds).
+ c.Response().Header().Set(echo.HeaderCacheControl, "public, max-age=2592000")
+ return false
}
// Route to serve the main app with HTML5 fallback for SPA behavior.