module HTTPX::Plugins::ResponseCache::RequestMethods

  1. lib/httpx/plugins/response_cache.rb

Methods

Public Class

  1. new

Public Instance

  1. cacheable_verb?
  2. cached_response
  3. merge_headers
  4. response_cache_key

Attributes

cached_response [RW]

points to a previously cached Response corresponding to this request.

Public Class methods

new(*)
[show source]
    # File lib/httpx/plugins/response_cache.rb
192 def initialize(*)
193   super
194   @cached_response = nil
195 end

Public Instance methods

cacheable_verb?()

returns whether this request is cacheable as per HTTP caching rules.

[show source]
    # File lib/httpx/plugins/response_cache.rb
203 def cacheable_verb?
204   CACHEABLE_VERBS.include?(@verb)
205 end
merge_headers(*)
[show source]
    # File lib/httpx/plugins/response_cache.rb
197 def merge_headers(*)
198   super
199   @response_cache_key = nil
200 end
response_cache_key()

returns a unique cache key as a String identifying this request

[show source]
    # File lib/httpx/plugins/response_cache.rb
208 def response_cache_key
209   @response_cache_key ||= begin
210     keys = [@verb, @uri.merge(path)]
211 
212     @options.supported_vary_headers.each do |field|
213       value = @headers[field]
214 
215       keys << value if value
216     end
217     Digest::SHA1.hexdigest("httpx-response-cache-#{keys.join("-")}")
218   end
219 end