Merge pull request #8233 from dhensby/pulls/4.2/caching-fixes

HTTP Caching fixes :/
This commit is contained in:
Ingo Schommer 2018-07-05 15:11:01 +12:00 committed by GitHub
commit 0bd613a3b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -26,6 +26,8 @@ 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,6 +92,9 @@ class HTTPCacheControlMiddleware implements HTTPMiddleware, Resettable
self::STATE_ENABLED => [ self::STATE_ENABLED => [
'must-revalidate' => true, 'must-revalidate' => true,
], ],
self::STATE_DEFAULT => [
'no-cache' => true,
],
]; ];
/** /**
@ -98,7 +103,7 @@ class HTTPCacheControlMiddleware implements HTTPMiddleware, Resettable
* @config * @config
* @var string * @var string
*/ */
protected static $defaultState = self::STATE_DISABLED; private static $defaultState = self::STATE_DEFAULT;
/** /**
* Current state * Current state
@ -766,14 +771,9 @@ class HTTPCacheControlMiddleware implements HTTPMiddleware, Resettable
} }
// Errors disable cache (unless some errors are cached intentionally by usercode) // Errors disable cache (unless some errors are cached intentionally by usercode)
if ($response->isError()) { if ($response->isError() || $response->isRedirect()) {
// Even if publicCache(true) is specified, errors will be uncacheable // Even if publicCache(true) is specified, errors will be uncacheable
$this->disableCache(true); $this->disableCache(true);
} }
// Don't cache redirects
if ($response->isRedirect()) {
$this->disableCache(true);
}
} }
} }