/** * Checks if the request and response can be cached, and if so, store it */ public function onComplete(CompleteEvent $event) { $request = $event->getRequest(); $response = $event->getResponse(); // Cache the response if it can be cached and isn't already if ($request->getConfig()->get('cache_lookup') === 'MISS' && call_user_func($this->canCache, $request) && Utils::canCacheResponse($response)) { $this->storage->cache($request, $response); } $this->addResponseHeaders($request, $response); }
/** * Checks if the request and response can be cached, and if so, store it. * * @param CompleteEvent $event */ public function onComplete(CompleteEvent $event) { $request = $event->getRequest(); $response = $event->getResponse(); // Cache the response if it can be cached and isn't already if ($request->getConfig()->get('cache_lookup') === 'MISS' && call_user_func($this->canCache, $request) && Utils::canCacheResponse($response)) { // Store the date when the response was cached $response->setHeader('X-Guzzle-Cache-Date', gmdate('D, d M Y H:i:s T', time())); $this->storage->cache($request, $response); } $this->addResponseHeaders($request, $response); }