Symfony\Component\HttpKernel\HttpCache\HttpCache::store PHP Method

store() protected method

Writes the Response to the cache.
protected store ( Request $request, Response $response )
$request Symfony\Component\HttpFoundation\Request A Request instance
$response Symfony\Component\HttpFoundation\Response A Response instance
    protected function store(Request $request, Response $response)
    {
        if (!$response->headers->has('Date')) {
            $response->setDate(\DateTime::createFromFormat('U', time()));
        }
        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);
    }

Usage Example

Example #1
0
 /**
  * @param  Request  $request
  * @param  Response $response
  * @throws \Exception
  */
 protected function store(Request $request, Response $response)
 {
     // Not cache sites with nocache header
     if ($this->containsNoCacheTag($request, $response)) {
         return;
     }
     parent::store($request, $response);
 }
All Usage Examples Of Symfony\Component\HttpKernel\HttpCache\HttpCache::store