Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. HttpCache.php

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\HttpCache

Code

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

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal