mirror of
https://github.com/willnorris/imageproxy.git
synced 2026-04-26 13:26:23 +02:00
allow overriding cache directives in responses
Add a new `-minCacheDuration` flag to specify a minimum duration to cache images for. Updates #28 Updates #144 Fixes #207 Fixes #208
This commit is contained in:
parent
82ce506905
commit
7502adde1c
6 changed files with 181 additions and 4 deletions
18
third_party/httpcache/httpcache.go
vendored
18
third_party/httpcache/httpcache.go
vendored
|
|
@ -5,10 +5,10 @@ import (
|
|||
"strings"
|
||||
)
|
||||
|
||||
type cacheControl map[string]string
|
||||
type CacheControl map[string]string
|
||||
|
||||
func parseCacheControl(headers http.Header) cacheControl {
|
||||
cc := cacheControl{}
|
||||
func ParseCacheControl(headers http.Header) CacheControl {
|
||||
cc := CacheControl{}
|
||||
ccHeader := headers.Get("Cache-Control")
|
||||
for _, part := range strings.Split(ccHeader, ",") {
|
||||
part = strings.Trim(part, " ")
|
||||
|
|
@ -24,3 +24,15 @@ func parseCacheControl(headers http.Header) cacheControl {
|
|||
}
|
||||
return cc
|
||||
}
|
||||
|
||||
func (cc CacheControl) String() string {
|
||||
parts := make([]string, 0, len(cc))
|
||||
for k, v := range cc {
|
||||
if v == "" {
|
||||
parts = append(parts, k)
|
||||
} else {
|
||||
parts = append(parts, k+"="+v)
|
||||
}
|
||||
}
|
||||
return strings.Join(parts, ", ")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue