public function Response::getTtl

Returns the response's time-to-live in seconds.

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.

@api

Return value

integer|null The TTL in seconds

1 call to Response::getTtl()
Response::isFresh in drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Response.php
Returns true if the response is "fresh".

File

drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Response.php, line 740

Class

Response
Response represents an HTTP response.

Namespace

Symfony\Component\HttpFoundation

Code

public function getTtl() {
  if ($maxAge = $this
    ->getMaxAge()) {
    return $maxAge - $this
      ->getAge();
  }
  return null;
}