You are here

protected function FinishResponseSubscriber::setExpiresNoCache in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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 280
Contains \Drupal\Core\EventSubscriber\FinishResponseSubscriber.

Class

FinishResponseSubscriber
Response subscriber to handle finished responses.

Namespace

Drupal\Core\EventSubscriber

Code

protected function setExpiresNoCache(Response $response) {
  $response
    ->setExpires(\DateTime::createFromFormat('j-M-Y H:i:s T', '19-Nov-1978 05:00:00 UTC'));
}