@@ -15,8 +15,8 @@ import (
15
15
"code.gitea.io/gitea/modules/setting"
16
16
)
17
17
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 ) {
20
20
directives := make ([]string , 0 , 2 + len (additionalDirectives ))
21
21
22
22
// "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
31
31
directives = append (directives , "max-age=0" , "private" , "must-revalidate" )
32
32
33
33
// 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 )
35
35
}
36
36
37
37
h .Set ("Cache-Control" , strings .Join (append (directives , additionalDirectives ... ), ", " ))
@@ -50,7 +50,7 @@ func HandleTimeCache(req *http.Request, w http.ResponseWriter, fi os.FileInfo) (
50
50
51
51
// HandleGenericTimeCache handles time-based caching for a HTTP request
52
52
func HandleGenericTimeCache (req * http.Request , w http.ResponseWriter , lastModified time.Time ) (handled bool ) {
53
- AddCacheControlToHeader (w .Header (), setting .StaticCacheTime )
53
+ SetCacheControlInHeader (w .Header (), setting .StaticCacheTime )
54
54
55
55
ifModifiedSince := req .Header .Get ("If-Modified-Since" )
56
56
if ifModifiedSince != "" {
@@ -81,7 +81,7 @@ func HandleGenericETagCache(req *http.Request, w http.ResponseWriter, etag strin
81
81
return true
82
82
}
83
83
}
84
- AddCacheControlToHeader (w .Header (), setting .StaticCacheTime )
84
+ SetCacheControlInHeader (w .Header (), setting .StaticCacheTime )
85
85
return false
86
86
}
87
87
@@ -125,6 +125,6 @@ func HandleGenericETagTimeCache(req *http.Request, w http.ResponseWriter, etag s
125
125
}
126
126
}
127
127
}
128
- AddCacheControlToHeader (w .Header (), setting .StaticCacheTime )
128
+ SetCacheControlInHeader (w .Header (), setting .StaticCacheTime )
129
129
return false
130
130
}
0 commit comments