function Response::isCacheable
Returns true if the response may safely be kept in a shared (surrogate) cache.
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 because there is no way to tell when or how to remove them from the cache.
Note that RFC 7231 and RFC 7234 possibly allow for a more permissive implementation, for example "status codes that are defined as cacheable by default [...] can be reused by a cache with heuristic expiration unless otherwise indicated" (https://tools.ietf.org/html/rfc7231#section-6.1)
@final
File
-
vendor/
symfony/ http-foundation/ Response.php, line 538
Class
- Response
- Response represents an HTTP response.
Namespace
Symfony\Component\HttpFoundationCode
public function isCacheable() : bool {
if (!\in_array($this->statusCode, [
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();
}