FIX If theres a max-age set remove no-cache and no-store

This commit is contained in:
Daniel Hensby 2018-07-05 22:52:04 +01:00
parent 2b1c55bc4e
commit cebed776ab
No known key found for this signature in database
GPG Key ID: D8DEBC4C8E7BC8B9
1 changed files with 8 additions and 0 deletions

View File

@ -522,6 +522,10 @@ class HTTPCacheControlMiddleware implements HTTPMiddleware, Resettable
// Affect all non-disabled states
$applyTo = [self::STATE_ENABLED, self::STATE_PRIVATE, self::STATE_PUBLIC, self::STATE_DEFAULT];
$this->setStateDirective($applyTo, 'max-age', $age);
if ($age) {
$this->removeStateDirective($applyTo, 'no-cache');
$this->removeStateDirective($applyTo, 'no-store');
}
return $this;
}
@ -538,6 +542,10 @@ class HTTPCacheControlMiddleware implements HTTPMiddleware, Resettable
// Affect all non-disabled states
$applyTo = [self::STATE_ENABLED, self::STATE_PRIVATE, self::STATE_PUBLIC, self::STATE_DEFAULT];
$this->setStateDirective($applyTo, 's-maxage', $age);
if ($age) {
$this->removeStateDirective($applyTo, 'no-cache');
$this->removeStateDirective($applyTo, 'no-store');
}
return $this;
}