From 14178c56bb0fbc8b0b5820539e7681a7defeff47 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sat, 23 Jul 2022 08:38:03 +0200 Subject: 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 Co-authored-by: wxiaoguang Co-authored-by: Andrew Thornton --- routers/install/routes.go | 2 ++ routers/web/base.go | 1 + 2 files changed, 3 insertions(+) (limited to 'routers') 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 { -- cgit v1.2.3