module HTTPX::Plugins::ResponseCache
def cacheable_request?(request)
def cacheable_request?(request) CACHEABLE_VERBS.include?(request.verb) && ( !request.headers.key?("cache-control") || !request.headers.get("cache-control").include?("no-store") ) end
def cacheable_response?(response)
def cacheable_response?(response) response.is_a?(Response) && ( response.cache_control.nil? || # TODO: !response.cache_control.include?("private") && is shared cache !response.cache_control.include?("no-store") ) && CACHEABLE_STATUS_CODES.include?(response.status) && # RFC 2616 13.4 - A response received with a status code of 200, 203, 206, 300, 301 or # 410 MAY be stored by a cache and used in reply to a subsequent # request, subject to the expiration mechanism, unless a cache-control # directive prohibits caching. However, a cache that does not support # the Range and Content-Range headers MUST NOT cache 206 (Partial # Content) responses. response.status != 206 && ( response.headers.key?("etag") || response.headers.key?("last-modified-at") || response.fresh? ) end
def cached_response?(response)
def cached_response?(response) response.is_a?(Response) && response.status == 304 end
def extra_options(options)
def extra_options(options) options.merge(response_cache_store: Store.new) end
def load_dependencies(*)
def load_dependencies(*) require_relative "response_cache/store" end