private function ParseCachingHeader($arr) {

    if (!empty($arr['cache-control'])) {
      if (strpos('no-cache', $arr['cache-control']) !== false) {
        return 0;
      }
      if (strpos('no-store', $arr['cache-control']) !== false) {
        return 0;
      }
      if (strpos('max-age=0', $arr['cache-control']) !== false) {
        return 0;
      }
      if (preg_match('/\bmax-age=(\d+),?\b/', $arr['cache-control'], $match)) {
        return (integer) $match[1];
      }
    }

    if (!empty($arr['expires'])) {
      if (preg_match('/^-\d+|0$/', $arr['expires'])) {
        return 0;
      }
      $epoch = strtotime($arr['expires']);
      $sec = $epoch - time();
      if ($sec > 0) {
        return $sec;
      }
      return 0;
    }

    return 0;
  }
private function ParseCachingHeader($arr) {

    if (!empty($arr['cache-control'])) {
      if (strpos('no-cache', $arr['cache-control']) !== false) {
        return 0;
      }
      if (strpos('no-store', $arr['cache-control']) !== false) {
        return 0;
      }
      if (strpos('max-age=0', $arr['cache-control']) !== false) {
        return 0;
      }
      if (preg_match('/\bmax-age=(\d+),?\b/', $arr['cache-control'], $match)) {
        return (integer) $match[1];
      }
    }

    if (!empty($arr['expires'])) {
      if (preg_match('/^-\d+|0$/', $arr['expires'])) {
        return 0;
      }
      $epoch = strtotime($arr['expires']);
      $sec = $epoch - time();
      if ($sec > 0) {
        return $sec;
      }
      return 0;
    }

    return 0;
  }
private function ParseCachingHeader ( $ arr ) { if ( ! empty ( $ arr [ 'cache-control' ] ) ) { if ( strpos ( 'no-cache' , $ arr [ 'cache-control' ] ) !== false ) { return 0 ; } if ( strpos ( 'no-store' , $ arr [ 'cache-control' ] ) !== false ) { return 0 ; } if ( strpos ( 'max-age=0' , $ arr [ 'cache-control' ] ) !== false ) { return 0 ; } if ( preg_match ( '/\bmax-age=(\d+),?\b/' , $ arr [ 'cache-control' ] , $ match ) ) { return ( integer ) $ match [ 1 ] ; } } if ( ! empty ( $ arr [ 'expires' ] ) ) { if ( preg_match ( '/^-\d+|0$/' , $ arr [ 'expires' ] ) ) { return 0 ; } $ epoch = strtotime ( $ arr [ 'expires' ] ) ; $ sec = $ epoch - time ( ) ; if ( $ sec > 0 ) { return $ sec ; } return 0 ; } return 0 ; }
Parses the response headers and returns the number of seconds
that will be the maximum caching time of our cached file.
@param  array  $arr
@return integer
Parses the response headers and returns the number of seconds that will be the maximum caching time of our cached file .