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;
    }