/** * If possible, store a response in cache after sending * * @param Event $event */ public function onRequestSent(Event $event) { $request = $event['request']; $response = $event['response']; if ($request->getParams()->get('cache.hit') === null && $this->canCache->canCacheRequest($request) && $this->canCache->canCacheResponse($response)) { $this->storage->cache($request, $response); } $this->addResponseHeaders($request, $response); }
/** * If possible, store a response in cache after sending * * @param Event $event */ public function onRequestSent(Event $event) { $request = $event['request']; $response = $event['response']; $cacheKey = $this->keyProvider->getCacheKey($request); if ($request->getParams()->get('cache.hit') === null && $this->canCache->canCacheRequest($request) && $this->canCache->canCacheResponse($response)) { $this->storage->cache($cacheKey, $response, $request->getParams()->get('cache.override_ttl')); } $this->addResponseHeaders($cacheKey, $request, $response); }
/** * If possible, store a response in cache after sending * * @param Event $event */ public function onRequestSent(Event $event) { $request = $event['request']; $response = $event['response']; if (isset($this->cached[$request])) { $cacheKey = $this->cached[$request]; unset($this->cached[$request]); if ($this->canCache->canCacheResponse($response)) { $this->storage->cache($cacheKey, $response, $request->getParams()->get('cache.override_ttl') ?: $response->getMaxAge()); } } }