mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Make augmentState method more efficient
This commit is contained in:
parent
cebed776ab
commit
9f1471332d
@ -778,17 +778,16 @@ class HTTPCacheControlMiddleware implements HTTPMiddleware, Resettable
|
|||||||
*/
|
*/
|
||||||
protected function augmentState(HTTPRequest $request, HTTPResponse $response)
|
protected function augmentState(HTTPRequest $request, HTTPResponse $response)
|
||||||
{
|
{
|
||||||
// If sessions exist we assume that the responses should not be cached by CDNs / proxies as we are
|
|
||||||
// likely to be supplying information relevant to the current user only
|
|
||||||
if ($request->getSession()->getAll()) {
|
|
||||||
// Don't force in case user code chooses to opt in to public caching
|
|
||||||
$this->privateCache();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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() || $response->isRedirect()) {
|
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);
|
||||||
|
} elseif ($request->getSession()->getAll()) {
|
||||||
|
// If sessions exist we assume that the responses should not be cached by CDNs / proxies as we are
|
||||||
|
// likely to be supplying information relevant to the current user only
|
||||||
|
|
||||||
|
// Don't force in case user code chooses to opt in to public caching
|
||||||
|
$this->privateCache();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user