/** * Validates a cached response to check it is still fresh and available * to the client. All validation is based on the `max-age` Cache-Control * header. * * // Get a response from the cache * $response = Request::$cache->get('foo'); * * // Test the response * if (Request_Cache::validate_get($response)) * { * // Return the valid cached response * return $response; * } * * @param Kohana_Response resposne * @return boolean */ public static function validate_get(Kohana_Response $response) { // Get the Cache-Control Header $cache_control = Request_Cache::parse_cache_control((array) $response->headers); // If the response has expired if ($cache_control['max-age'] + time() < time()) { // Remove this entry Request_Cache::delete($key); // return false return FALSE; } // Return true return TRUE; }