MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / AddBrowserCache

Method AddBrowserCache

agent/utils/nginx/components/location.go:261–281  ·  view source on GitHub ↗
(cacheTime int, cacheUint string)

Source from the content-addressed store, hash-verified

259}
260
261func (l *Location) AddBrowserCache(cacheTime int, cacheUint string) {
262 l.RemoveDirective("add_header", []string{"Cache-Control", "no-cache"})
263 l.RemoveDirectiveByFullParams("if", []string{"(", "$uri", "~*", `"\.(gif|png|jpg|css|js|woff|woff2)$"`, ")"})
264 l.RemoveDirectiveByFullParams("if", []string{"(", "$uri", "~*", `"\.(gif|png|jpg|css|js|woff|woff2|jpeg|svg|webp|avif)$"`, ")"})
265 directives := l.GetDirectives()
266 newDir := &Directive{
267 Name: "if",
268 Parameters: []string{"(", "$uri", "~*", `"\.(gif|png|jpg|css|js|woff|woff2|jpeg|svg|webp|avif)$"`, ")"},
269 Block: &Block{},
270 }
271 block := &Block{}
272 block.Directives = append(block.Directives, &Directive{
273 Name: "expires",
274 Parameters: []string{strconv.Itoa(cacheTime) + cacheUint},
275 })
276 newDir.Block = block
277 directives = append(directives, newDir)
278 l.Directives = directives
279 l.CacheTime = cacheTime
280 l.CacheUint = cacheUint
281}
282
283func (l *Location) AddBroswerNoCache() {
284 l.RemoveDirective("add_header", []string{"Cache-Control", "no-cache"})

Callers 1

OperateProxyMethod · 0.95

Calls 3

RemoveDirectiveMethod · 0.95
GetDirectivesMethod · 0.95

Tested by

no test coverage detected