protected function HttpCache::fetch

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.

Parameters

Request $request A Request instance:

Boolean $catch whether to process exceptions:

Return value

Response A Response instance

1 call to HttpCache::fetch()
HttpCache::lookup in drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/HttpCache.php
Lookups a Response from the cache for the given Request.

File

drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/HttpCache.php, line 405

Class

HttpCache
Cache provides HTTP caching.

Namespace

Symfony\Component\HttpKernel\HttpCache

Code

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;
}