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

Breadcrumb

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

function HttpCache::store

Writes the Response to the cache.

Throws

\Exception

2 calls to HttpCache::store()
HttpCache::fetch in vendor/symfony/http-kernel/HttpCache/HttpCache.php
Unconditionally fetches a fresh response from the backend and stores it in the cache if is cacheable.
HttpCache::validate in vendor/symfony/http-kernel/HttpCache/HttpCache.php
Validates that a cache entry is fresh.

File

vendor/symfony/http-kernel/HttpCache/HttpCache.php, line 587

Class

HttpCache
Cache provides HTTP caching.

Namespace

Symfony\Component\HttpKernel\HttpCache

Code

protected function store(Request $request, Response $response) : void {
    try {
        $restoreHeaders = [];
        foreach ($this->options['skip_response_headers'] as $header) {
            if (!$response->headers
                ->has($header)) {
                continue;
            }
            $restoreHeaders[$header] = $response->headers
                ->all($header);
            $response->headers
                ->remove($header);
        }
        $this->store
            ->write($request, $response);
        $this->record($request, 'store');
        $response->headers
            ->set('Age', $response->getAge());
    } catch (\Exception $e) {
        $this->record($request, 'store-failed');
        if ($this->options['debug']) {
            throw $e;
        }
    } finally {
        foreach ($restoreHeaders as $header => $values) {
            $response->headers
                ->set($header, $values);
        }
    }
    // now that the response is cached, release the lock
    $this->store
        ->unlock($request);
}
RSS feed
Powered by Drupal