You are here

private function ApeSubscriber::setCacheHeader in Advanced Page Expiration 8

Sets the cache control header.

Parameters

\Symfony\Component\HttpKernel\Event\FilterResponseEvent $event: The event to process.

int $maxAge: The cache expiration age, in seconds.

1 call to ApeSubscriber::setCacheHeader()
ApeSubscriber::onRespond in src/EventSubscriber/ApeSubscriber.php
Sets extra headers on successful responses.

File

src/EventSubscriber/ApeSubscriber.php, line 165

Class

ApeSubscriber
Alter Cache-control header based on configuration of ape.

Namespace

Drupal\ape\EventSubscriber

Code

private function setCacheHeader(FilterResponseEvent $event, $maxAge) {
  $response = $event
    ->getResponse();
  $value = 'no-cache, must-revalidate';
  if ($this
    ->checkCacheable($event, $maxAge)) {
    $value = 'public, max-age=' . $maxAge;
  }
  $response->headers
    ->set('Cache-Control', $value);
}