Forwards the Request to the backend and determines whether the response should be stored.
This methods is triggered when the cache missed or a reload is required.
Request $request A Request instance:
Boolean $catch whether to process exceptions:
protected function fetch(Request $request, $catch = false) {
$subRequest = clone $request;
// send no head requests because we want content
$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 ($this
->isPrivateRequest($request) && !$response->headers
->hasCacheControlDirective('public')) {
$response
->setPrivate(true);
}
elseif ($this->options['default_ttl'] > 0 && null === $response
->getTtl() && !$response->headers
->getCacheControlDirective('must-revalidate')) {
$response
->setTtl($this->options['default_ttl']);
}
if ($response
->isCacheable()) {
$this
->store($request, $response);
}
return $response;
}