class HTTP::Response::Caching

def current_age

Returns:
  • (Numeric) - the current age (in seconds) of this response
def current_age
  now = Time.now
  age_value  = headers.get(HTTP::Headers::AGE).map(&:to_i).max || 0
  apparent_age = [0, received_at - server_response_time].max
  corrected_received_age = [apparent_age, age_value].max
  response_delay = [0, received_at - requested_at].max
  corrected_initial_age = corrected_received_age + response_delay
  resident_time = [0, now - received_at].max
  corrected_initial_age + resident_time
end