public function DenyOnCacheControlOverride::check in Cache Control Override 8
Determines whether it is save to store a page in the cache.
Parameters
\Symfony\Component\HttpFoundation\Response $response: The response which is about to be sent to the client.
\Symfony\Component\HttpFoundation\Request $request: The request object.
Return value
string|null Either static::DENY or NULL. Calling code may attempt to store a page in the cache unless static::DENY is returned. Returns NULL if the policy policy is not specified for the given response.
Overrides ResponsePolicyInterface::check
File
- src/
PageCache/ DenyOnCacheControlOverride.php, line 18
Class
- DenyOnCacheControlOverride
- Cache policy for responses that have a bubbled max-age=0.
Namespace
Drupal\cache_control_override\PageCacheCode
public function check(Response $response, Request $request) {
if (!$response instanceof CacheableResponseInterface) {
return NULL;
}
if ($response
->getCacheableMetadata()
->getCacheMaxAge() === 0) {
// @TODO: This will affect users using Internal Page Cache as well, find a way to document that.
return static::DENY;
}
}