Bluz\Http\CacheControl::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 ($maxAge = $this->getMaxAge()) {
            return $maxAge - $this->getAge();
        }
        return null;
    }

Usage Example

Example #1
0
 /**
  * Test Client Ttl
  */
 public function testClientTtl()
 {
     $this->cacheControl->setClientTtl(3600);
     $this->assertEquals(3600, $this->cacheControl->getTtl());
     $this->assertEquals(3600, $this->cacheControl->getMaxAge());
     $this->assertEquals('max-age=3600', $this->response->getHeader('Cache-Control'));
 }