예제 #1
0
 /**
  * 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);
 }
예제 #3
0
 /**
  * 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());
         }
     }
 }