Symfony\Component\HttpFoundation\Response::getTtl PHP Method

getTtl() public method

It returns null when no freshness information is present in the response. When the responses TTL is <= 0, the response may not be served from cache without first revalidating with the origin.
public getTtl ( ) : integer | null
return integer | null The TTL in seconds
    public function getTtl()
    {
        if (null !== $maxAge = $this->getMaxAge()) {
            return $maxAge - $this->getAge();
        }
    }

Usage Example

 /**
  * {@inheritdoc}
  */
 public function updateMetadata(Response $response, BlockContextInterface $blockContext = null)
 {
     if ($this->currentTtl === null) {
         $this->currentTtl = $response->getTtl();
     }
     if ($response->isCacheable() !== null && $response->getTtl() < $this->currentTtl) {
         $this->currentTtl = $response->getTtl();
     }
 }
All Usage Examples Of Symfony\Component\HttpFoundation\Response::getTtl