forked from forgejo/forgejo
HTTP cache rework and enable caching for storage assets (#13569)
This enabled HTTP time-based cache for storage assets, primarily avatars. I have not observed If-Modified-Since from browsers during tests but I guess it's good to support regardless. It introduces a new generic httpcache module that can handle both time-based and etag-based caching. Additionally, manifest.json and robots.txt are now also cachable.
This commit is contained in:
parent
9ec5e6c40b
commit
0615b668dc
8 changed files with 91 additions and 36 deletions
|
@ -6,10 +6,12 @@ package routes
|
|||
|
||||
import (
|
||||
"encoding/gob"
|
||||
"net/http"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/auth"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/httpcache"
|
||||
"code.gitea.io/gitea/modules/lfs"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/options"
|
||||
|
@ -977,6 +979,8 @@ func RegisterMacaronRoutes(m *macaron.Macaron) {
|
|||
|
||||
// Progressive Web App
|
||||
m.Get("/manifest.json", templates.JSONRenderer(), func(ctx *context.Context) {
|
||||
ctx.Resp.Header().Set("Cache-Control", httpcache.GetCacheControl())
|
||||
ctx.Resp.Header().Set("Last-Modified", setting.AppStartTime.Format(http.TimeFormat))
|
||||
ctx.HTML(200, "pwa/manifest_json")
|
||||
})
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue