mirror of
https://github.com/usememos/memos.git
synced 2025-12-10 22:26:05 +08:00
chore: caching resource files accelerates second requests (#4614)
* cache assets files * Apply suggestions from code review * Update server/router/frontend/frontend.go * Update server/router/frontend/frontend.go --------- Co-authored-by: Johnny <yourselfhosted@gmail.com>
This commit is contained in:
parent
3cc0e255ce
commit
ebf13c4dff
1 changed files with 6 additions and 1 deletions
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue