diff options
author | silverwind <me@silverwind.io> | 2022-07-23 08:38:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-23 14:38:03 +0800 |
commit | 14178c56bb0fbc8b0b5820539e7681a7defeff47 (patch) | |
tree | 4da90c0d0761a1cf7a066738fc434b78ba02b33f /modules/context/api.go | |
parent | d9608c4e76401ffdd5958e1944ba0a17ded825b9 (diff) | |
download | gitea-14178c56bb0fbc8b0b5820539e7681a7defeff47.tar.gz gitea-14178c56bb0fbc8b0b5820539e7681a7defeff47.zip |
Add Cache-Control header to html and api responses, add no-transform (#20432)
`no-transform` allegedly disables CloudFlare auto-minify and we did not
set caching headers on html or api requests, which seems good to have
regardless.
Transformation is still allowed for asset requests.
Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'modules/context/api.go')
-rw-r--r-- | modules/context/api.go | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/modules/context/api.go b/modules/context/api.go index 558a9f51ee..b9d130e2a8 100644 --- a/modules/context/api.go +++ b/modules/context/api.go @@ -16,6 +16,7 @@ import ( repo_model "code.gitea.io/gitea/models/repo" "code.gitea.io/gitea/modules/cache" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/httpcache" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/web/middleware" @@ -268,6 +269,7 @@ func APIContexter() func(http.Handler) http.Handler { } } + httpcache.AddCacheControlToHeader(ctx.Resp.Header(), 0, "no-transform") ctx.Resp.Header().Set(`X-Frame-Options`, setting.CORSConfig.XFrameOptions) ctx.Data["Context"] = &ctx |