function HttpCache::fetch
Unconditionally fetches a fresh response from the backend and stores it in the cache if is cacheable.
Parameters
bool $catch Whether to process exceptions:
2 calls to HttpCache::fetch()
- HttpCache::handle in vendor/
symfony/ http-kernel/ HttpCache/ HttpCache.php - Handles a Request to convert it to a Response.
- HttpCache::lookup in vendor/
symfony/ http-kernel/ HttpCache/ HttpCache.php - Lookups a Response from the cache for the given Request.
File
-
vendor/
symfony/ http-kernel/ HttpCache/ HttpCache.php, line 424
Class
- HttpCache
- Cache provides HTTP caching.
Namespace
Symfony\Component\HttpKernel\HttpCacheCode
protected function fetch(Request $request, bool $catch = false) : Response {
$subRequest = clone $request;
// send no head requests because we want content
if ('HEAD' === $request->getMethod()) {
$subRequest->setMethod('GET');
}
// avoid that the backend sends no content
$subRequest->headers
->remove('If-Modified-Since');
$subRequest->headers
->remove('If-None-Match');
$response = $this->forward($subRequest, $catch);
if ($response->isCacheable()) {
$this->store($request, $response);
}
return $response;
}