public function PageCacheResponsePolicy::check in Media Download 1.2.x
Same name and namespace in other branches
- 1.0.x src/PageCacheResponsePolicy.php \Drupal\media_download\PageCacheResponsePolicy::check()
- 1.1.x src/PageCacheResponsePolicy.php \Drupal\media_download\PageCacheResponsePolicy::check()
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/
PageCacheResponsePolicy.php, line 27
Class
- PageCacheResponsePolicy
- Deny caching of BinaryFileResponse and StreamedResponse class hierarchies.
Namespace
Drupal\media_downloadCode
public function check(Response $response, Request $request) {
// Currently it is not possible to cache binary file or streamed responses.
// @see https://github.com/symfony/symfony/issues/9128#issuecomment-25088678
if ($response instanceof BinaryFileResponse || $response instanceof StreamedResponse) {
return static::DENY;
}
}