Add support for missing Cache-Control directives (#8619)

no-cache, only-if-cached and no-store directives are
being enforced in this PR.
This commit is contained in:
poornas
2019-12-06 18:19:36 -08:00
committed by Nitish Tiwari
parent 476111968a
commit be0c8b1ec0
2 changed files with 40 additions and 6 deletions

View File

@@ -185,12 +185,17 @@ func (c *cacheObjects) GetObjectNInfo(ctx context.Context, bucket, object string
cacheReader, cacheErr := c.get(ctx, dcache, bucket, object, rs, h, opts)
if cacheErr == nil {
cc = cacheControlOpts(cacheReader.ObjInfo)
if !cc.isStale(cacheReader.ObjInfo.ModTime) {
if (!cc.isEmpty() && !cc.isStale(cacheReader.ObjInfo.ModTime)) ||
cc.onlyIfCached {
// This is a cache hit, mark it so
c.cacheStats.incHit()
c.cacheStats.incBytesServed(cacheReader.ObjInfo.Size)
return cacheReader, nil
}
if cc.noStore {
c.cacheStats.incMiss()
return c.GetObjectNInfo(ctx, bucket, object, rs, h, lockType, opts)
}
}
// Reaching here implies cache miss