src/Guzzle/Plugin/Cache/CachePlugin.php
public function canResponseSatisfyFailedRequest(RequestInterface $request, Response $response)
    {
        $reqc = $request->getHeader('Cache-Control');
        $resc = $response->getHeader('Cache-Control');
        $requestStaleIfError = $reqc ? $reqc->getDirective('stale-if-error') : null;
        $responseStaleIfError = $resc ? $resc->getDirective('stale-if-error') : null;

        if (!$requestStaleIfError && !$responseStaleIfError) {
            return false;
        }

        if (is_numeric($requestStaleIfError) && $response->getAge() - $response->getMaxAge() > $requestStaleIfError) {
            return false;
        }

        if (is_numeric($responseStaleIfError) && $response->getAge() - $response->getMaxAge() > $responseStaleIfError) {
            return false;
        }

        return true;
    }
public function canResponseSatisfyFailedRequest(RequestInterface $request, Response $response)
    {
        $reqc = $request->getHeader('Cache-Control');
        $resc = $response->getHeader('Cache-Control');
        $requestStaleIfError = $reqc ? $reqc->getDirective('stale-if-error') : null;
        $responseStaleIfError = $resc ? $resc->getDirective('stale-if-error') : null;

        if (!$requestStaleIfError && !$responseStaleIfError) {
            return false;
        }

        if (is_numeric($requestStaleIfError) && $response->getAge() - $response->getMaxAge() > $requestStaleIfError) {
            return false;
        }

        if (is_numeric($responseStaleIfError) && $response->getAge() - $response->getMaxAge() > $responseStaleIfError) {
            return false;
        }

        return true;
    }
public function canResponseSatisfyFailedRequest ( RequestInterface $ request , Response $ response ) { $ reqc = $ request -> getHeader ( 'Cache-Control' ) ; $ resc = $ response -> getHeader ( 'Cache-Control' ) ; $ requestStaleIfError = $ reqc ? $ reqc -> getDirective ( 'stale-if-error' ) : null ; $ responseStaleIfError = $ resc ? $ resc -> getDirective ( 'stale-if-error' ) : null ; if ( ! $ requestStaleIfError && ! $ responseStaleIfError ) { return false ; } if ( is_numeric ( $ requestStaleIfError ) && $ response -> getAge ( ) - $ response -> getMaxAge ( ) > $ requestStaleIfError ) { return false ; } if ( is_numeric ( $ responseStaleIfError ) && $ response -> getAge ( ) - $ response -> getMaxAge ( ) > $ responseStaleIfError ) { return false ; } return true ; }
Check if a cache response satisfies a failed request's caching constraints

@param RequestInterface $request  Request to validate
@param Response         $response Response to validate

@return bool
Check if a cache response satisfies a failed request s caching constraints