public function Response::getMaxAge

Same name in this branch

Gets the number of seconds from the current time in which this response is still considered fresh

Return value

int|null Returns the number of seconds

1 call to Response::getMaxAge()
Response::getFreshness in drupal/core/vendor/guzzle/http/Guzzle/Http/Message/Response.php
Get the freshness of the response by returning the difference of the maximum lifetime of the response and the age of the response (max-age - age).

File

drupal/core/vendor/guzzle/http/Guzzle/Http/Message/Response.php, line 827

Class

Response
Guzzle HTTP response object

Namespace

Guzzle\Http\Message

Code

public function getMaxAge() {

  // s-max-age, then max-age, then Expires
  if ($age = $this
    ->getCacheControlDirective('s-maxage')) {
    return $age;
  }
  if ($age = $this
    ->getCacheControlDirective('max-age')) {
    return $age;
  }
  if ($this
    ->getHeader('Expires')) {
    return strtotime($this
      ->getExpires()) - time();
  }
  return null;
}