Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. FinishResponseSubscriber.php

function FinishResponseSubscriber::setResponseNotCacheable

Add Cache-Control and Expires headers to a response which is not cacheable.

Parameters

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

\Symfony\Component\HttpFoundation\Request $request: A request object.

1 call to FinishResponseSubscriber::setResponseNotCacheable()
FinishResponseSubscriber::onRespond in core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php
Sets extra headers on successful responses.

File

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

Class

FinishResponseSubscriber
Response subscriber to handle finished responses.

Namespace

Drupal\Core\EventSubscriber

Code

protected function setResponseNotCacheable(Response $response, Request $request) {
    $this->setCacheControlNoCache($response);
    $this->setExpiresNoCache($response);
    // There is no point in sending along headers necessary for cache
    // revalidation, if caching by proxies and browsers is denied in the first
    // place. Therefore remove ETag, Last-Modified and Vary in that case.
    $response->setEtag(NULL);
    $response->setLastModified(NULL);
    $response->headers
        ->remove('Vary');
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal