Set X-Cache and X-Cache-Lookup headers for cache (#8794)

X-Cache sets cache status of HIT if object is
served from the disk cache, or MISS otherwise.
X-Cache-Lookup is set to HIT if object was found
in the cache even if not served (for e.g. if cache
 entry was invalidated by ETag verification)
This commit is contained in:
poornas
2020-01-10 20:21:13 -08:00
committed by kannappanr
parent 2bf6cf0e15
commit 9199033db7
6 changed files with 50 additions and 10 deletions

View File

@@ -28,6 +28,24 @@ import (
"github.com/minio/minio/cmd/crypto"
)
// CacheStatusType - whether the request was served from cache.
type CacheStatusType string
const (
// CacheHit - whether object was served from cache.
CacheHit CacheStatusType = "HIT"
// CacheMiss - object served from backend.
CacheMiss CacheStatusType = "MISS"
)
func (c CacheStatusType) String() string {
if c != "" {
return string(c)
}
return string(CacheMiss)
}
type cacheControl struct {
expiry time.Time
maxAge int