function FinishResponseSubscriber::setCacheControlNoCache

Same name in other branches
  1. 9 core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php \Drupal\Core\EventSubscriber\FinishResponseSubscriber::setCacheControlNoCache()
  2. 10 core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php \Drupal\Core\EventSubscriber\FinishResponseSubscriber::setCacheControlNoCache()
  3. 11.x core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php \Drupal\Core\EventSubscriber\FinishResponseSubscriber::setCacheControlNoCache()

Disable caching in the browser and for HTTP/1.1 proxies and clients.

Parameters

\Symfony\Component\HttpFoundation\Response $response: A response object.

1 call to FinishResponseSubscriber::setCacheControlNoCache()
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 275

Class

FinishResponseSubscriber
Response subscriber to handle finished responses.

Namespace

Drupal\Core\EventSubscriber

Code

protected function setCacheControlNoCache(Response $response) {
    $response->headers
        ->set('Cache-Control', 'no-cache, must-revalidate');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.