src/CacheStorage.php
private function getTtl(ResponseInterface $response)
    {
        $ttl = 0;

        if ($cacheControl = $response->getHeader('Cache-Control')) {
            $maxAge = Utils::getDirective($response, 'max-age');
            if (is_numeric($maxAge)) {
                $ttl += $maxAge;
            }

            // According to RFC5861 stale headers are *in addition* to any
            // max-age values.
            $stale = Utils::getDirective($response, 'stale-if-error');
            if (is_numeric($stale)) {
                $ttl += $stale;
            }
        } elseif ($expires = $response->getHeader('Expires')) {
            $ttl += strtotime($expires) - time();
        }

        return $ttl ?: $this->defaultTtl;
    }
private function getTtl(ResponseInterface $response)
    {
        $ttl = 0;

        if ($cacheControl = $response->getHeader('Cache-Control')) {
            $maxAge = Utils::getDirective($response, 'max-age');
            if (is_numeric($maxAge)) {
                $ttl += $maxAge;
            }

            // According to RFC5861 stale headers are *in addition* to any
            // max-age values.
            $stale = Utils::getDirective($response, 'stale-if-error');
            if (is_numeric($stale)) {
                $ttl += $stale;
            }
        } elseif ($expires = $response->getHeader('Expires')) {
            $ttl += strtotime($expires) - time();
        }

        return $ttl ?: $this->defaultTtl;
    }
private function getTtl ( ResponseInterface $ response ) { $ ttl = 0 ; if ( $ cacheControl = $ response -> getHeader ( 'Cache-Control' ) ) { $ maxAge = Utils :: getDirective ( $ response , 'max-age' ) ; if ( is_numeric ( $ maxAge ) ) { $ ttl += $ maxAge ; } // According to RFC5861 stale headers are *in addition* to any // max-age values. $ stale = Utils :: getDirective ( $ response , 'stale-if-error' ) ; if ( is_numeric ( $ stale ) ) { $ ttl += $ stale ; } } elseif ( $ expires = $ response -> getHeader ( 'Expires' ) ) { $ ttl += strtotime ( $ expires ) - time ( ) ; } return $ ttl ? : $ this -> defaultTtl ; }
Return the TTL to use when caching a Response.

@param ResponseInterface $response The response being cached.

@return int The TTL in seconds.
Return the TTL to use when caching a Response .