src/Utils.php
public static function canCacheResponse(ResponseInterface $response)
    {
        static $cacheCodes = [200, 203, 300, 301, 410];

        // Check if the response is cacheable based on the code
        if (!in_array((int) $response->getStatusCode(), $cacheCodes)) {
            return false;
        }

        // Make sure a valid body was returned and can be cached
        $body = $response->getBody();
        if ($body && (!$body->isReadable() || !$body->isSeekable())) {
            return false;
        }

        // Never cache no-store resources (this is a private cache, so private
        // can be cached)
        if (self::getDirective($response, 'no-store')) {
            return false;
        }

        // Don't fool with Content-Range requests for now
        if ($response->hasHeader('Content-Range')) {
            return false;
        }

        $freshness = self::getFreshness($response);

        return $freshness === null                    // No freshness info.
            || $freshness >= 0                        // It's fresh
            || $response->hasHeader('ETag')           // Can validate
            || $response->hasHeader('Last-Modified'); // Can validate
    }
public static function canCacheResponse(ResponseInterface $response)
    {
        static $cacheCodes = [200, 203, 300, 301, 410];

        // Check if the response is cacheable based on the code
        if (!in_array((int) $response->getStatusCode(), $cacheCodes)) {
            return false;
        }

        // Make sure a valid body was returned and can be cached
        $body = $response->getBody();
        if ($body && (!$body->isReadable() || !$body->isSeekable())) {
            return false;
        }

        // Never cache no-store resources (this is a private cache, so private
        // can be cached)
        if (self::getDirective($response, 'no-store')) {
            return false;
        }

        // Don't fool with Content-Range requests for now
        if ($response->hasHeader('Content-Range')) {
            return false;
        }

        $freshness = self::getFreshness($response);

        return $freshness === null                    // No freshness info.
            || $freshness >= 0                        // It's fresh
            || $response->hasHeader('ETag')           // Can validate
            || $response->hasHeader('Last-Modified'); // Can validate
    }
public static function canCacheResponse ( ResponseInterface $ response ) { static $ cacheCodes = [ 200 , 203 , 300 , 301 , 410 ] ; // Check if the response is cacheable based on the code if ( ! in_array ( ( int ) $ response -> getStatusCode ( ) , $ cacheCodes ) ) { return false ; } // Make sure a valid body was returned and can be cached $ body = $ response -> getBody ( ) ; if ( $ body && ( ! $ body -> isReadable ( ) || ! $ body -> isSeekable ( ) ) ) { return false ; } // Never cache no-store resources (this is a private cache, so private // can be cached) if ( self :: getDirective ( $ response , 'no-store' ) ) { return false ; } // Don't fool with Content-Range requests for now if ( $ response -> hasHeader ( 'Content-Range' ) ) { return false ; } $ freshness = self :: getFreshness ( $ response ) ; return $ freshness === null // No freshness info. || $ freshness >= 0 // It's fresh || $ response -> hasHeader ( 'ETag' ) // Can validate || $ response -> hasHeader ( 'Last-Modified' ) ; // Can validate }
Determines if a response can be cached.

@param ResponseInterface $response Response to check

@return bool
Determines if a response can be cached .