You are here

protected function HttpCache::store 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::store()

Writes the Response to the cache.

Parameters

Request $request A Request instance:

Response $response A Response instance:

Throws

\Exception

2 calls to HttpCache::store()
HttpCache::fetch in vendor/symfony/http-kernel/HttpCache/HttpCache.php
Forwards the Request to the backend and determines whether the response should be stored.
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 601

Class

HttpCache
Cache provides HTTP caching.

Namespace

Symfony\Component\HttpKernel\HttpCache

Code

protected function store(Request $request, Response $response) {
  try {
    $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;
    }
  }

  // now that the response is cached, release the lock
  $this->store
    ->unlock($request);
}