class PageCacheResponsePolicy in Media Download 1.1.x
Same name and namespace in other branches
- 1.2.x src/PageCacheResponsePolicy.php \Drupal\media_download\PageCacheResponsePolicy
- 1.0.x src/PageCacheResponsePolicy.php \Drupal\media_download\PageCacheResponsePolicy
Deny caching of BinaryFileResponse and StreamedResponse class hierarchies.
Copyright (C) 2021 Library Solutions, LLC (et al.).
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
Hierarchy
- class \Drupal\media_download\PageCacheResponsePolicy implements ResponsePolicyInterface
Expanded class hierarchy of PageCacheResponsePolicy
1 string reference to 'PageCacheResponsePolicy'
1 service uses PageCacheResponsePolicy
File
- src/
PageCacheResponsePolicy.php, line 22
Namespace
Drupal\media_downloadView source
class PageCacheResponsePolicy implements ResponsePolicyInterface {
/**
* {@inheritdoc}
*/
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;
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PageCacheResponsePolicy:: |
public | function |
Determines whether it is save to store a page in the cache. Overrides ResponsePolicyInterface:: |
|
ResponsePolicyInterface:: |
constant | Deny storage of a page in the cache. |