This plugin adds support for retrying requests when certain errors happen.
Methods
Public Class
Classes and Modules
Public Class methods
cacheable_request?(request)
[show source]
# File lib/httpx/plugins/response_cache.rb 21 def cacheable_request?(request) 22 CACHEABLE_VERBS.include?(request.verb) && 23 ( 24 !request.headers.key?("cache-control") || !request.headers.get("cache-control").include?("no-store") 25 ) 26 end
cacheable_response?(response)
[show source]
# File lib/httpx/plugins/response_cache.rb 28 def cacheable_response?(response) 29 response.is_a?(Response) && 30 ( 31 response.cache_control.nil? || 32 # TODO: !response.cache_control.include?("private") && is shared cache 33 !response.cache_control.include?("no-store") 34 ) && 35 CACHEABLE_STATUS_CODES.include?(response.status) && 36 # RFC 2616 13.4 - A response received with a status code of 200, 203, 206, 300, 301 or 37 # 410 MAY be stored by a cache and used in reply to a subsequent 38 # request, subject to the expiration mechanism, unless a cache-control 39 # directive prohibits caching. However, a cache that does not support 40 # the Range and Content-Range headers MUST NOT cache 206 (Partial 41 # Content) responses. 42 response.status != 206 && ( 43 response.headers.key?("etag") || response.headers.key?("last-modified") || response.fresh? 44 ) 45 end
cached_response?(response)
[show source]
# File lib/httpx/plugins/response_cache.rb 47 def cached_response?(response) 48 response.is_a?(Response) && response.status == 304 49 end
extra_options(options)
[show source]
# File lib/httpx/plugins/response_cache.rb 51 def extra_options(options) 52 options.merge(response_cache_store: Store.new) 53 end
load_dependencies(*)
[show source]
# File lib/httpx/plugins/response_cache.rb 17 def load_dependencies(*) 18 require_relative "response_cache/store" 19 end