You are here

public function NoServerError::check in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/PageCache/ResponsePolicy/NoServerError.php \Drupal\Core\PageCache\ResponsePolicy\NoServerError::check()

Determines whether it is save to store a page in the cache.

Parameters

\Symfony\Component\HttpFoundation\Response $response: The response which is about to be sent to the client.

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

Return value

string|NULL Either static::DENY or NULL. Calling code may attempt to store a page in the cache unless static::DENY is returned. Returns NULL if the policy policy is not specified for the given response.

Overrides ResponsePolicyInterface::check

File

core/lib/Drupal/Core/PageCache/ResponsePolicy/NoServerError.php, line 22
Contains \Drupal\Core\PageCache\ResponsePolicy\NoServerError.

Class

NoServerError
A policy denying caching of a server error (HTTP 5xx) responses.

Namespace

Drupal\Core\PageCache\ResponsePolicy

Code

public function check(Response $response, Request $request) {
  if ($response
    ->isServerError()) {
    return static::DENY;
  }
}