public function onBefore(BeforeEvent $event, $name)
    {
        $request = $event->getRequest();

        if($request->getMethod() == 'GET' && $this->lifetime)
        {
            $response_key = $this->getCacheResponseKey($request->getUrl());
            $body_key = $this->getCacheBodyKey($request->getUrl());

            if($this->cache->has($response_key) && $this->cache->has($body_key))
            {
                $response = $this->cache->get($response_key);
                $body = $this->cache->get($body_key);
                $response->setBody(Stream::factory($body));
                
                $event->intercept($response);
            }
        }
    }
public function onBefore(BeforeEvent $event, $name)
    {
        $request = $event->getRequest();

        if($request->getMethod() == 'GET' && $this->lifetime)
        {
            $response_key = $this->getCacheResponseKey($request->getUrl());
            $body_key = $this->getCacheBodyKey($request->getUrl());

            if($this->cache->has($response_key) && $this->cache->has($body_key))
            {
                $response = $this->cache->get($response_key);
                $body = $this->cache->get($body_key);
                $response->setBody(Stream::factory($body));
                
                $event->intercept($response);
            }
        }
    }
public function onBefore ( BeforeEvent $ event , $ name ) { $ request = $ event -> getRequest ( ) ; if ( $ request -> getMethod ( ) == 'GET' && $ this -> lifetime ) { $ response_key = $ this -> getCacheResponseKey ( $ request -> getUrl ( ) ) ; $ body_key = $ this -> getCacheBodyKey ( $ request -> getUrl ( ) ) ; if ( $ this -> cache -> has ( $ response_key ) && $ this -> cache -> has ( $ body_key ) ) { $ response = $ this -> cache -> get ( $ response_key ) ; $ body = $ this -> cache -> get ( $ body_key ) ; $ response -> setBody ( Stream :: factory ( $ body ) ) ; $ event -> intercept ( $ response ) ; } } }
Intercept any request if cached

@param  BeforeEvent $event [description]
@param  [type]      $name  [description]
@return void
Intercept any request if cached