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'));
}
doc_Drupal
2016-10-29 09:14:58
Comments
Leave a Comment

Please login to continue.