You are here

public function Response::getMaxAge in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/http-foundation/Response.php \Symfony\Component\HttpFoundation\Response::getMaxAge()

Returns the number of seconds after the time specified in the response's Date header when the response should no longer be considered fresh.

First, it checks for a s-maxage directive, then a max-age directive, and then it falls back on an expires header. It returns null when no maximum age can be established.

Return value

int|null Number of seconds

2 calls to Response::getMaxAge()
Response::expire in vendor/symfony/http-foundation/Response.php
Marks the response stale by setting the Age header to be equal to the maximum age of the response.
Response::getTtl in vendor/symfony/http-foundation/Response.php
Returns the response's time-to-live in seconds.

File

vendor/symfony/http-foundation/Response.php, line 703

Class

Response
Response represents an HTTP response.

Namespace

Symfony\Component\HttpFoundation

Code

public function getMaxAge() {
  if ($this->headers
    ->hasCacheControlDirective('s-maxage')) {
    return (int) $this->headers
      ->getCacheControlDirective('s-maxage');
  }
  if ($this->headers
    ->hasCacheControlDirective('max-age')) {
    return (int) $this->headers
      ->getCacheControlDirective('max-age');
  }
  if (null !== $this
    ->getExpires()) {
    return $this
      ->getExpires()
      ->format('U') - $this
      ->getDate()
      ->format('U');
  }
}