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
187 def initialize(*)
188   super
189   @cached_response = nil
190 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
198 def cacheable_verb?
199   CACHEABLE_VERBS.include?(@verb)
200 end
merge_headers(*)
[show source]
    # File lib/httpx/plugins/response_cache.rb
192 def merge_headers(*)
193   super
194   @response_cache_key = nil
195 end
response_cache_key()

returns a unique cache key as a String identifying this request

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