You are here

protected function HttpCache::fetch in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/http-kernel/HttpCache/HttpCache.php \Symfony\Component\HttpKernel\HttpCache\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:

bool $catch whether to process exceptions:

Return value

Response A Response instance

1 call to HttpCache::fetch()
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 433

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 ($response
    ->isCacheable()) {
    $this
      ->store($request, $response);
  }
  return $response;
}