summaryrefslogtreecommitdiffstats
path: root/routers
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 /routers
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 'routers')
-rw-r--r--routers/install/routes.go2
-rw-r--r--routers/web/base.go1
2 files changed, 3 insertions, 0 deletions
diff --git a/routers/install/routes.go b/routers/install/routes.go
index 32829ede9e..fdabcb9dc2 100644
--- a/routers/install/routes.go
+++ b/routers/install/routes.go
@@ -9,6 +9,7 @@ import (
"net/http"
"path"
+ "code.gitea.io/gitea/modules/httpcache"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/public"
"code.gitea.io/gitea/modules/setting"
@@ -62,6 +63,7 @@ func installRecovery() func(next http.Handler) http.Handler {
"SignedUserName": "",
}
+ httpcache.AddCacheControlToHeader(w.Header(), 0, "no-transform")
w.Header().Set(`X-Frame-Options`, setting.CORSConfig.XFrameOptions)
if !setting.IsProd {
diff --git a/routers/web/base.go b/routers/web/base.go
index c7ade55a61..30a24a1275 100644
--- a/routers/web/base.go
+++ b/routers/web/base.go
@@ -158,6 +158,7 @@ func Recovery() func(next http.Handler) http.Handler {
store["SignedUserName"] = ""
}
+ httpcache.AddCacheControlToHeader(w.Header(), 0, "no-transform")
w.Header().Set(`X-Frame-Options`, setting.CORSConfig.XFrameOptions)
if !setting.IsProd {