You are here

public function AuthcacheP13nAddCacheControlHeaderFilter::filter in Authenticated User Page Caching (Authcache) 7.2

Add Cache-Control header.

Overrides AuthcacheP13nFilterInterface::filter

File

modules/authcache_p13n/includes/AuthcacheP13nAddCacheControlHeaderFilter.inc, line 48
Defines request filter for adding HTTP cache-control headers.

Class

AuthcacheP13nAddCacheControlHeaderFilter
Request filter for adding HTTP cache-control headers.

Code

public function filter($event, $input) {
  if ($this->cacheMaxage) {
    if ($this->cacheGranularity
      ->is(AuthcacheP13nCacheGranularity::PER_USER)) {
      $this->coreService
        ->drupalAddHttpHeader('Cache-Control', 'private, max-age=' . $this->cacheMaxage);
    }
    else {
      $this->coreService
        ->drupalAddHttpHeader('Cache-Control', 'public, max-age=' . $this->cacheMaxage);
    }
  }
  else {
    $this->coreService
      ->drupalAddHttpHeader('Cache-Control', 'no-cache, must-revalidate, post-check=0, pre-check=0');
  }
  return $input;
}