aboutsummaryrefslogtreecommitdiffstats
path: root/modules/context/context.go
diff options
context:
space:
mode:
authorsilverwind <me@silverwind.io>2022-07-23 08:38:03 +0200
committerGitHub <noreply@github.com>2022-07-23 14:38:03 +0800
commit14178c56bb0fbc8b0b5820539e7681a7defeff47 (patch)
tree4da90c0d0761a1cf7a066738fc434b78ba02b33f /modules/context/context.go
parentd9608c4e76401ffdd5958e1944ba0a17ded825b9 (diff)
downloadgitea-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/context.go')
-rw-r--r--modules/context/context.go2
1 files changed, 2 insertions, 0 deletions
diff --git a/modules/context/context.go b/modules/context/context.go
index 68f8a1b408..8824911619 100644
--- a/modules/context/context.go
+++ b/modules/context/context.go
@@ -28,6 +28,7 @@ import (
"code.gitea.io/gitea/modules/base"
mc "code.gitea.io/gitea/modules/cache"
"code.gitea.io/gitea/modules/git"
+ "code.gitea.io/gitea/modules/httpcache"
"code.gitea.io/gitea/modules/json"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
@@ -767,6 +768,7 @@ func Contexter() func(next http.Handler) http.Handler {
}
}
+ httpcache.AddCacheControlToHeader(ctx.Resp.Header(), 0, "no-transform")
ctx.Resp.Header().Set(`X-Frame-Options`, setting.CORSConfig.XFrameOptions)
ctx.Data["CsrfToken"] = ctx.csrf.GetToken()