mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
State default should be state enabled (no-cache is an enabled state)
This commit is contained in:
parent
601bb4d768
commit
fd8448889c
@ -26,8 +26,6 @@ class HTTPCacheControlMiddleware implements HTTPMiddleware, Resettable
|
|||||||
|
|
||||||
const STATE_DISABLED = 'disabled';
|
const STATE_DISABLED = 'disabled';
|
||||||
|
|
||||||
const STATE_DEFAULT = 'default';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate response for the given request
|
* Generate response for the given request
|
||||||
*
|
*
|
||||||
@ -90,12 +88,9 @@ class HTTPCacheControlMiddleware implements HTTPMiddleware, Resettable
|
|||||||
'must-revalidate' => true,
|
'must-revalidate' => true,
|
||||||
],
|
],
|
||||||
self::STATE_ENABLED => [
|
self::STATE_ENABLED => [
|
||||||
'must-revalidate' => true,
|
|
||||||
],
|
|
||||||
self::STATE_DEFAULT => [
|
|
||||||
'no-cache' => true,
|
'no-cache' => true,
|
||||||
'must-revalidate' => true,
|
'must-revalidate' => true,
|
||||||
],
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -104,7 +99,7 @@ class HTTPCacheControlMiddleware implements HTTPMiddleware, Resettable
|
|||||||
* @config
|
* @config
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private static $defaultState = self::STATE_DEFAULT;
|
private static $defaultState = self::STATE_ENABLED;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Current state
|
* Current state
|
||||||
@ -520,7 +515,7 @@ class HTTPCacheControlMiddleware implements HTTPMiddleware, Resettable
|
|||||||
public function setMaxAge($age)
|
public function setMaxAge($age)
|
||||||
{
|
{
|
||||||
// Affect all non-disabled states
|
// Affect all non-disabled states
|
||||||
$applyTo = [self::STATE_ENABLED, self::STATE_PRIVATE, self::STATE_PUBLIC, self::STATE_DEFAULT];
|
$applyTo = [self::STATE_ENABLED, self::STATE_PRIVATE, self::STATE_PUBLIC];
|
||||||
$this->setStateDirective($applyTo, 'max-age', $age);
|
$this->setStateDirective($applyTo, 'max-age', $age);
|
||||||
if ($age) {
|
if ($age) {
|
||||||
$this->removeStateDirective($applyTo, 'no-cache');
|
$this->removeStateDirective($applyTo, 'no-cache');
|
||||||
@ -540,7 +535,7 @@ class HTTPCacheControlMiddleware implements HTTPMiddleware, Resettable
|
|||||||
public function setSharedMaxAge($age)
|
public function setSharedMaxAge($age)
|
||||||
{
|
{
|
||||||
// Affect all non-disabled states
|
// Affect all non-disabled states
|
||||||
$applyTo = [self::STATE_ENABLED, self::STATE_PRIVATE, self::STATE_PUBLIC, self::STATE_DEFAULT];
|
$applyTo = [self::STATE_ENABLED, self::STATE_PRIVATE, self::STATE_PUBLIC];
|
||||||
$this->setStateDirective($applyTo, 's-maxage', $age);
|
$this->setStateDirective($applyTo, 's-maxage', $age);
|
||||||
if ($age) {
|
if ($age) {
|
||||||
$this->removeStateDirective($applyTo, 'no-cache');
|
$this->removeStateDirective($applyTo, 'no-cache');
|
||||||
@ -558,7 +553,7 @@ class HTTPCacheControlMiddleware implements HTTPMiddleware, Resettable
|
|||||||
*/
|
*/
|
||||||
public function setMustRevalidate($mustRevalidate = true)
|
public function setMustRevalidate($mustRevalidate = true)
|
||||||
{
|
{
|
||||||
$applyTo = [self::STATE_ENABLED, self::STATE_PRIVATE, self::STATE_PUBLIC, self::STATE_DEFAULT];
|
$applyTo = [self::STATE_ENABLED, self::STATE_PRIVATE, self::STATE_PUBLIC];
|
||||||
$this->setStateDirective($applyTo, 'must-revalidate', $mustRevalidate);
|
$this->setStateDirective($applyTo, 'must-revalidate', $mustRevalidate);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user