function FinishResponseSubscriber::setExpiresNoCache
Same name in other branches
- 9 core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php \Drupal\Core\EventSubscriber\FinishResponseSubscriber::setExpiresNoCache()
- 8.9.x core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php \Drupal\Core\EventSubscriber\FinishResponseSubscriber::setExpiresNoCache()
- 11.x core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php \Drupal\Core\EventSubscriber\FinishResponseSubscriber::setExpiresNoCache()
Disable caching in ancient browsers and for HTTP/1.0 proxies and clients.
HTTP/1.0 proxies do not support the Vary header, so prevent any caching by sending an Expires date in the past. HTTP/1.1 clients ignore the Expires header if a Cache-Control: max-age= directive is specified (see RFC 2616, section 14.9.3).
Parameters
\Symfony\Component\HttpFoundation\Response $response: A response object.
3 calls to FinishResponseSubscriber::setExpiresNoCache()
- FinishResponseSubscriber::onRespond in core/
lib/ Drupal/ Core/ EventSubscriber/ FinishResponseSubscriber.php - Sets extra headers on successful responses.
- FinishResponseSubscriber::setResponseCacheable in core/
lib/ Drupal/ Core/ EventSubscriber/ FinishResponseSubscriber.php - Add Cache-Control and Expires headers to a cacheable response.
- FinishResponseSubscriber::setResponseNotCacheable in core/
lib/ Drupal/ Core/ EventSubscriber/ FinishResponseSubscriber.php - Add Cache-Control and Expires headers to a response which is not cacheable.
File
-
core/
lib/ Drupal/ Core/ EventSubscriber/ FinishResponseSubscriber.php, line 325
Class
- FinishResponseSubscriber
- Response subscriber to handle finished responses.
Namespace
Drupal\Core\EventSubscriberCode
protected function setExpiresNoCache(Response $response) {
$response->setExpires(\DateTime::createFromFormat('j-M-Y H:i:s T', '19-Nov-1978 05:00:00 UTC'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.