@@ -15,8 +15,8 @@ import (
1515 "code.gitea.io/gitea/modules/setting"
1616)
1717
18- // AddCacheControlToHeader adds suitable cache-control headers to response
19- func AddCacheControlToHeader (h http.Header , maxAge time.Duration , additionalDirectives ... string ) {
18+ // SetCacheControlInHeader sets suitable cache-control headers in the response
19+ func SetCacheControlInHeader (h http.Header , maxAge time.Duration , additionalDirectives ... string ) {
2020 directives := make ([]string , 0 , 2 + len (additionalDirectives ))
2121
2222 // "max-age=0 + must-revalidate" (aka "no-cache") is preferred instead of "no-store"
@@ -31,7 +31,7 @@ func AddCacheControlToHeader(h http.Header, maxAge time.Duration, additionalDire
3131 directives = append (directives , "max-age=0" , "private" , "must-revalidate" )
3232
3333 // to remind users they are using non-prod setting.
34- h .Add ("X-Gitea-Debug" , "RUN_MODE=" + setting .RunMode )
34+ h .Set ("X-Gitea-Debug" , "RUN_MODE=" + setting .RunMode )
3535 }
3636
3737 h .Set ("Cache-Control" , strings .Join (append (directives , additionalDirectives ... ), ", " ))
@@ -50,7 +50,7 @@ func HandleTimeCache(req *http.Request, w http.ResponseWriter, fi os.FileInfo) (
5050
5151// HandleGenericTimeCache handles time-based caching for a HTTP request
5252func HandleGenericTimeCache (req * http.Request , w http.ResponseWriter , lastModified time.Time ) (handled bool ) {
53- AddCacheControlToHeader (w .Header (), setting .StaticCacheTime )
53+ SetCacheControlInHeader (w .Header (), setting .StaticCacheTime )
5454
5555 ifModifiedSince := req .Header .Get ("If-Modified-Since" )
5656 if ifModifiedSince != "" {
@@ -81,7 +81,7 @@ func HandleGenericETagCache(req *http.Request, w http.ResponseWriter, etag strin
8181 return true
8282 }
8383 }
84- AddCacheControlToHeader (w .Header (), setting .StaticCacheTime )
84+ SetCacheControlInHeader (w .Header (), setting .StaticCacheTime )
8585 return false
8686}
8787
@@ -125,6 +125,6 @@ func HandleGenericETagTimeCache(req *http.Request, w http.ResponseWriter, etag s
125125 }
126126 }
127127 }
128- AddCacheControlToHeader (w .Header (), setting .StaticCacheTime )
128+ SetCacheControlInHeader (w .Header (), setting .StaticCacheTime )
129129 return false
130130}
0 commit comments