(cacheTime int, cacheUint string)
| 259 | } |
| 260 | |
| 261 | func (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 | |
| 283 | func (l *Location) AddBroswerNoCache() { |
| 284 | l.RemoveDirective("add_header", []string{"Cache-Control", "no-cache"}) |
no test coverage detected