mirror of
https://github.com/willnorris/imageproxy.git
synced 2026-05-09 20:12:39 +02:00
add -forceCache flag to override no-store and private directives
The httpcache package is intended only to be used in private caches, so it will cache responses marked `private` like normal. However, imageproxy is a shared cache, so these response should not be cached under normal circumstances. This change introduces a potentially breaking change to start respecting the `private` cache directive in responses. This also adds a new `-forceCache` flag to ignore the `private` and `no-store` directives, and cache all responses regardless.
This commit is contained in:
parent
8170536e41
commit
b529c116c0
5 changed files with 104 additions and 16 deletions
6
third_party/httpcache/httpcache.go
vendored
6
third_party/httpcache/httpcache.go
vendored
|
|
@ -2,6 +2,7 @@ package httpcache
|
|||
|
||||
import (
|
||||
"net/http"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
|
@ -17,9 +18,9 @@ func ParseCacheControl(headers http.Header) CacheControl {
|
|||
}
|
||||
if strings.ContainsRune(part, '=') {
|
||||
keyval := strings.Split(part, "=")
|
||||
cc[strings.Trim(keyval[0], " ")] = strings.Trim(keyval[1], ",")
|
||||
cc[strings.ToLower(strings.Trim(keyval[0], " "))] = strings.Trim(keyval[1], ",")
|
||||
} else {
|
||||
cc[part] = ""
|
||||
cc[strings.ToLower(part)] = ""
|
||||
}
|
||||
}
|
||||
return cc
|
||||
|
|
@ -34,5 +35,6 @@ func (cc CacheControl) String() string {
|
|||
parts = append(parts, k+"="+v)
|
||||
}
|
||||
}
|
||||
sort.StringSlice(parts).Sort()
|
||||
return strings.Join(parts, ", ")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue