public function EsiResponseCacheStrategy::update

Updates the Response HTTP headers based on the embedded Responses.

Parameters

Response $response:

Overrides EsiResponseCacheStrategyInterface::update

File

drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/EsiResponseCacheStrategy.php, line 55

Class

EsiResponseCacheStrategy
EsiResponseCacheStrategy knows how to compute the Response cache HTTP header based on the different ESI response cache headers.

Namespace

Symfony\Component\HttpKernel\HttpCache

Code

public function update(Response $response) {

  // if we only have one Response, do nothing
  if (1 === count($this->ttls)) {
    return;
  }
  if (!$this->cacheable) {
    $response->headers
      ->set('Cache-Control', 'no-cache, must-revalidate');
    return;
  }
  if (null !== ($maxAge = min($this->maxAges))) {
    $response
      ->setSharedMaxAge($maxAge);
    $response->headers
      ->set('Age', $maxAge - min($this->ttls));
  }
  $response
    ->setMaxAge(0);
}