You are here

class DenyOnCacheControlOverride in Cache Control Override 8

Cache policy for responses that have a bubbled max-age=0.

Hierarchy

Expanded class hierarchy of DenyOnCacheControlOverride

1 string reference to 'DenyOnCacheControlOverride'
cache_control_override.services.yml in ./cache_control_override.services.yml
cache_control_override.services.yml
1 service uses DenyOnCacheControlOverride
cache_control_override.page_cache_response_policy.deny_on_cache_override in ./cache_control_override.services.yml
Drupal\cache_control_override\PageCache\DenyOnCacheControlOverride

File

src/PageCache/DenyOnCacheControlOverride.php, line 13

Namespace

Drupal\cache_control_override\PageCache
View source
class DenyOnCacheControlOverride implements ResponsePolicyInterface {

  /**
   * {@inheritdoc}
   */
  public function check(Response $response, Request $request) {
    if (!$response instanceof CacheableResponseInterface) {
      return NULL;
    }
    if ($response
      ->getCacheableMetadata()
      ->getCacheMaxAge() === 0) {

      // @TODO: This will affect users using Internal Page Cache as well, find a way to document that.
      return static::DENY;
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DenyOnCacheControlOverride::check public function Determines whether it is save to store a page in the cache. Overrides ResponsePolicyInterface::check
ResponsePolicyInterface::DENY constant Deny storage of a page in the cache.