Module: HTTPX::Plugins::ResponseCache
- Defined in:
- lib/httpx/plugins/response_cache.rb,
lib/httpx/plugins/response_cache/store.rb,
lib/httpx/plugins/response_cache/file_store.rb
Overview
Defined Under Namespace
Modules: InstanceMethods, OptionsMethods, RequestMethods, ResponseMethods
Classes: FileStore, Store
Class Method Summary
collapse
Class Method Details
.cacheable_request?(request) ⇒ Boolean
21
22
23
24
25
26
|
# File 'lib/httpx/plugins/response_cache.rb', line 21
def cacheable_request?(request)
CACHEABLE_VERBS.include?(request.verb) &&
(
!request..key?("cache-control") || !request..get("cache-control").include?("no-store")
)
end
|
.cacheable_response?(response) ⇒ Boolean
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/httpx/plugins/response_cache.rb', line 28
def cacheable_response?(response)
response.is_a?(Response) &&
(
response.cache_control.nil? ||
!response.cache_control.include?("no-store")
) &&
CACHEABLE_STATUS_CODES.include?(response.status) &&
response.status != 206 && (
response..key?("etag") || response..key?("last-modified") || response.fresh?
)
end
|
.cached_response?(response) ⇒ Boolean
47
48
49
|
# File 'lib/httpx/plugins/response_cache.rb', line 47
def cached_response?(response)
response.is_a?(Response) && response.status == 304
end
|
51
52
53
|
# File 'lib/httpx/plugins/response_cache.rb', line 51
def (options)
options.merge(response_cache_store: Store.new)
end
|
.load_dependencies ⇒ Object
17
18
19
|
# File 'lib/httpx/plugins/response_cache.rb', line 17
def load_dependencies(*)
require_relative "response_cache/store"
end
|