public function Response::isCacheable

Returns true if the response is worth caching under any circumstance.

Responses marked "private" with an explicit Cache-Control directive are considered uncacheable.

Responses with neither a freshness lifetime (Expires, max-age) nor cache validator (Last-Modified, ETag) are considered uncacheable.

@api

Return value

Boolean true if the response is worth caching, false otherwise

File

drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Response.php, line 473

Class

Response
Response represents an HTTP response.

Namespace

Symfony\Component\HttpFoundation

Code

public function isCacheable() {
  if (!in_array($this->statusCode, array(
    200,
    203,
    300,
    301,
    302,
    404,
    410,
  ))) {
    return false;
  }
  if ($this->headers
    ->hasCacheControlDirective('no-store') || $this->headers
    ->getCacheControlDirective('private')) {
    return false;
  }
  return $this
    ->isValidateable() || $this
    ->isFresh();
}