private function getMaxAge(ResponseInterface $response)
    {
        if (!in_array('max-age', $this->config['respect_response_cache_directives'], true)) {
            return $this->config['default_ttl'];
        }

        // check for max age in the Cache-Control header
        $maxAge = $this->getCacheControlDirective($response, 'max-age');
        if (!is_bool($maxAge)) {
            $ageHeaders = $response->getHeader('Age');
            foreach ($ageHeaders as $age) {
                return $maxAge - ((int) $age);
            }

            return (int) $maxAge;
        }

        // check for ttl in the Expires header
        $headers = $response->getHeader('Expires');
        foreach ($headers as $header) {
            return (new \DateTime($header))->getTimestamp() - (new \DateTime())->getTimestamp();
        }

        return $this->config['default_ttl'];
    }
private function getMaxAge(ResponseInterface $response)
    {
        if (!in_array('max-age', $this->config['respect_response_cache_directives'], true)) {
            return $this->config['default_ttl'];
        }

        // check for max age in the Cache-Control header
        $maxAge = $this->getCacheControlDirective($response, 'max-age');
        if (!is_bool($maxAge)) {
            $ageHeaders = $response->getHeader('Age');
            foreach ($ageHeaders as $age) {
                return $maxAge - ((int) $age);
            }

            return (int) $maxAge;
        }

        // check for ttl in the Expires header
        $headers = $response->getHeader('Expires');
        foreach ($headers as $header) {
            return (new \DateTime($header))->getTimestamp() - (new \DateTime())->getTimestamp();
        }

        return $this->config['default_ttl'];
    }
private function getMaxAge ( ResponseInterface $ response ) { if ( ! in_array ( 'max-age' , $ this -> config [ 'respect_response_cache_directives' ] , true ) ) { return $ this -> config [ 'default_ttl' ] ; } // check for max age in the Cache-Control header $ maxAge = $ this -> getCacheControlDirective ( $ response , 'max-age' ) ; if ( ! is_bool ( $ maxAge ) ) { $ ageHeaders = $ response -> getHeader ( 'Age' ) ; foreach ( $ ageHeaders as $ age ) { return $ maxAge - ( ( int ) $ age ) ; } return ( int ) $ maxAge ; } // check for ttl in the Expires header $ headers = $ response -> getHeader ( 'Expires' ) ; foreach ( $ headers as $ header ) { return ( new \ DateTime ( $ header ) ) -> getTimestamp ( ) - ( new \ DateTime ( ) ) -> getTimestamp ( ) ; } return $ this -> config [ 'default_ttl' ] ; }
Get a ttl in seconds. It could return null if we do not respect cache headers and got no defaultTtl.

@param ResponseInterface $response

@return int|null
Get a ttl in seconds . It could return null if we do not respect cache headers and got no defaultTtl .