Class: Hurley::HttpCache::Request
- Inherits:
-
Request
- Object
- Request
- Hurley::HttpCache::Request
- Defined in:
- lib/hurley/http_cache/request.rb
Overview
Internal: Delegator that extends the Hurley::Request class with some behavior required for the HTTP caching mechanism.
Instance Method Summary collapse
-
#cacheable? ⇒ Boolean
Internal: Check if the request can be cached.
-
#matches?(request, response) ⇒ Boolean
Internal: Check if a pair of existing request and response matches the current request object.
-
#no_cache? ⇒ Boolean
Internal: Check if the request can’t be cached, accordingly to the ‘Cache-Control’ header.
-
#serializable_hash ⇒ Object
Internal: Get a Hash that represents the request that can be properly serialized.
Instance Method Details
#cacheable? ⇒ Boolean
Internal: Check if the request can be cached.
Returns true or false.
14 15 16 17 18 |
# File 'lib/hurley/http_cache/request.rb', line 14 def cacheable? return false if verb != :get && verb != :head return false if cache_control.no_store? true end |
#matches?(request, response) ⇒ Boolean
Internal: Check if a pair of existing request and response matches the current request object.
request - The Hash of the request that was cached. response - The Hash of the response that was cached.
Returns true or false.
27 28 29 |
# File 'lib/hurley/http_cache/request.rb', line 27 def matches?(request, response) verb.to_s == request['verb'] && vary_matches?(request, response) end |
#no_cache? ⇒ Boolean
Internal: Check if the request can’t be cached, accordingly to the ‘Cache-Control’ header.
Returns true or false.
35 36 37 |
# File 'lib/hurley/http_cache/request.rb', line 35 def no_cache? cache_control.no_cache? end |
#serializable_hash ⇒ Object
Internal: Get a Hash that represents the request that can be properly serialized.
Returns a Hash.
43 44 45 46 47 48 49 |
# File 'lib/hurley/http_cache/request.rb', line 43 def serializable_hash { 'verb' => verb.to_s, 'url' => url, 'header' => header.to_hash } end |