Module: HTTPX::Plugins::ResponseCache::RequestMethods

Defined in:
lib/httpx/plugins/response_cache.rb,
sig/plugins/response_cache.rbs

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#cached_responseresponseCacheResponse?

Returns the value of attribute cached_response.

Returns:

  • (responseCacheResponse, nil)


23
24
25
# File 'sig/plugins/response_cache.rbs', line 23

def cached_response
  @cached_response
end

#optionsresponseCacheOptions (readonly)

Returns the value of attribute options.

Returns:

  • (responseCacheOptions)


24
25
26
# File 'sig/plugins/response_cache.rbs', line 24

def options
  @options
end

Instance Method Details

#cacheable_verb?Boolean

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

Returns:

  • (Boolean)


148
149
150
# File 'lib/httpx/plugins/response_cache.rb', line 148

def cacheable_verb?
  CACHEABLE_VERBS.include?(@verb)
end

#response_cache_keyObject

returns a unique cache key as a String identifying this request



153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/httpx/plugins/response_cache.rb', line 153

def response_cache_key
  @response_cache_key ||= begin
    keys = [@verb, @uri.merge(path)]

    @options.supported_vary_headers.each do |field|
      value = @headers[field]

      keys << value if value
    end
    Digest::SHA1.hexdigest("httpx-response-cache-#{keys.join("-")}")
  end
end