src/CacheSubscriber.php
public function onError(ErrorEvent $event)
    {
        $request = $event->getRequest();

        if (!call_user_func($this->canCache, $request)) {
            return;
        }

        $response = $this->storage->fetch($request);

        // Intercept the failed response if possible
        if ($response && $this->validateFailed($request, $response)) {
            $request->getConfig()->set('cache_hit', 'error');
            $response->setHeader('Age', Utils::getResponseAge($response));
            $event->intercept($response);
        }
    }
public function onError(ErrorEvent $event)
    {
        $request = $event->getRequest();

        if (!call_user_func($this->canCache, $request)) {
            return;
        }

        $response = $this->storage->fetch($request);

        // Intercept the failed response if possible
        if ($response && $this->validateFailed($request, $response)) {
            $request->getConfig()->set('cache_hit', 'error');
            $response->setHeader('Age', Utils::getResponseAge($response));
            $event->intercept($response);
        }
    }
public function onError ( ErrorEvent $ event ) { $ request = $ event -> getRequest ( ) ; if ( ! call_user_func ( $ this -> canCache , $ request ) ) { return ; } $ response = $ this -> storage -> fetch ( $ request ) ; // Intercept the failed response if possible if ( $ response && $ this -> validateFailed ( $ request , $ response ) ) { $ request -> getConfig ( ) -> set ( 'cache_hit' , 'error' ) ; $ response -> setHeader ( 'Age' , Utils :: getResponseAge ( $ response ) ) ; $ event -> intercept ( $ response ) ; } }
If the request failed, then check if a cached response would suffice.

@param ErrorEvent $event
If the request failed then check if a cached response would suffice .