class GdsApi::JsonClient

def do_request_with_cache(method, url, params = nil, additional_headers = {})

def do_request_with_cache(method, url, params = nil, additional_headers = {})
  # Only read GET requests from the cache: any other request methods should
  # always be passed through. Note that this means HEAD requests won't get
  # cached, but that would involve separating the cache by method and URL.
  # Also, we don't generally make HEAD requests.
  use_cache = (method == :get)
  if use_cache
    cached_response = @cache[url]
    return cached_response if cached_response
  end
  response = do_request(method, url, params, additional_headers)
  if use_cache
    cache_time = response_cache_time(response)
    # If cache_time is nil, this will fall back on @cache's default
    @cache.store(url, response, cache_time)
  end
  response
end