protected function FinishResponseSubscriber::setExpiresNoCache

protected FinishResponseSubscriber::setExpiresNoCache(Response $response)

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.

File

core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php, line 275

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'));
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!EventSubscriber!FinishResponseSubscriber.php/function/FinishResponseSubscriber::setExpiresNoCache/8.1.x