Module: HTTPX::Plugins::ResponseCache::RequestMethods
- Defined in:
- lib/httpx/plugins/response_cache.rb
Instance Attribute Summary collapse
-
#cached_response ⇒ Object
points to a previously cached Response corresponding to this request.
Instance Method Summary collapse
-
#cacheable_verb? ⇒ Boolean
returns whether this request is cacheable as per HTTP caching rules.
- #initialize ⇒ Object
- #merge_headers ⇒ Object
-
#response_cache_key ⇒ Object
returns a unique cache key as a String identifying this request.
Instance Attribute Details
#cached_response ⇒ Object
points to a previously cached Response corresponding to this request.
187 188 189 |
# File 'lib/httpx/plugins/response_cache.rb', line 187 def cached_response @cached_response end |
Instance Method Details
#cacheable_verb? ⇒ Boolean
returns whether this request is cacheable as per HTTP caching rules.
200 201 202 |
# File 'lib/httpx/plugins/response_cache.rb', line 200 def cacheable_verb? CACHEABLE_VERBS.include?(@verb) end |
#initialize ⇒ Object
189 190 191 192 |
# File 'lib/httpx/plugins/response_cache.rb', line 189 def initialize(*) super @cached_response = nil end |
#merge_headers ⇒ Object
194 195 196 197 |
# File 'lib/httpx/plugins/response_cache.rb', line 194 def merge_headers(*) super @response_cache_key = nil end |
#response_cache_key ⇒ Object
returns a unique cache key as a String identifying this request
205 206 207 208 209 210 211 212 213 214 215 216 |
# File 'lib/httpx/plugins/response_cache.rb', line 205 def response_cache_key @response_cache_key ||= begin keys = [@verb, @uri] .supported_vary_headers.each do |field| value = @headers[field] keys << value if value end Digest::SHA1.hexdigest("httpx-response-cache-#{keys.join("-")}") end end |