function PageCache::fetch
Fetches a response from the backend and stores it in the cache.
Parameters
\Symfony\Component\HttpFoundation\Request $request: A request object.
int $type: The type of the request (one of HttpKernelInterface::MAIN_REQUEST or HttpKernelInterface::SUB_REQUEST)
bool $catch: Whether to catch exceptions or not
Return value
\Symfony\Component\HttpFoundation\Response A response object.
See also
drupal_page_header()
1 call to PageCache::fetch()
- PageCache::lookup in core/
modules/ page_cache/ src/ StackMiddleware/ PageCache.php  - Retrieves a response from the cache or fetches it from the backend.
 
File
- 
              core/
modules/ page_cache/ src/ StackMiddleware/ PageCache.php, line 189  
Class
- PageCache
 - Executes the page caching before the main kernel takes over the request.
 
Namespace
Drupal\page_cache\StackMiddlewareCode
protected function fetch(Request $request, $type = self::MAIN_REQUEST, $catch = TRUE) {
  /** @var \Symfony\Component\HttpFoundation\Response $response */
  $response = $this->httpKernel
    ->handle($request, $type, $catch);
  // Only set the 'X-Drupal-Cache' header if caching is allowed for this
  // response.
  if ($this->storeResponse($request, $response)) {
    $response->headers
      ->set('X-Drupal-Cache', 'MISS');
  }
  return $response;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.