You are here

public static function HttpHelper::cachedRequestGetExpire in Helper 7

1 call to HttpHelper::cachedRequestGetExpire()
HttpHelper::cachedRequest in lib/HttpHelper.php

File

lib/HttpHelper.php, line 49

Class

HttpHelper

Code

public static function cachedRequestGetExpire($response, $options) {
  if (isset($options['cache']['expire'])) {
    return $options['cache']['expire'];
  }
  elseif (!empty($response->headers['cache-control']) && strpos($response->headers['cache-control'], 'no-cache') !== FALSE) {

    // Respect the Cache-Control: no-cache header.
    return FALSE;
  }
  elseif (!empty($response->headers['cache-control']) && preg_match('/max-age=(\\d+)/', $response->headers['cache-control'], $matches)) {

    // Respect the Cache-Control: max-age=SECONDS header.
    return REQUEST_TIME + $matches[1];
  }
  elseif (!empty($response->headers['expires']) && ($expire = strtotime($response->headers['expires']))) {
    return $expire;
  }
  else {
    return CACHE_TEMPORARY;
  }
}