response_bank 1.3.0 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/response_bank/middleware.rb +1 -2
- data/lib/response_bank/response_cache_handler.rb +16 -7
- data/lib/response_bank/version.rb +1 -1
- data/lib/response_bank.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2fbaca21dd928ad2b387d10300acbbb61dedca00a8cdab23247484af8c749bf
|
4
|
+
data.tar.gz: a4f81948c53b5e574e5bd3cb3a3c9d621c387a3040706aa0ee873ffc5dab5362
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3a0956f4ab5b627d4e80f4349c16cc830b49eecb602357b52aedc3e60703ddd2547bca663656d28b4525dfd9f47a4b67d226f9eaca4322ff9da1acfa1351c00
|
7
|
+
data.tar.gz: 602e5ed4aca5b96d30b61fed0d90c814689424b986374f9f6030ee4f03c6c41db6138cd7542be475bd86c3cb94fcd77453d52a6e7b58c5d954f50ca2a25ead3b
|
@@ -22,8 +22,7 @@ module ResponseBank
|
|
22
22
|
|
23
23
|
if env['cacheable.cache']
|
24
24
|
if [200, 404, 301, 304].include?(status)
|
25
|
-
headers['ETag'] = env['cacheable.key']
|
26
|
-
|
25
|
+
headers['ETag'] = %{"#{env['cacheable.key']}"}
|
27
26
|
end
|
28
27
|
|
29
28
|
if [200, 404, 301].include?(status) && env['cacheable.miss']
|
@@ -145,11 +145,14 @@ module ResponseBank
|
|
145
145
|
# regen
|
146
146
|
@headers.merge!(headers)
|
147
147
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
148
|
+
if @headers['Content-Encoding']
|
149
|
+
if !@env['HTTP_ACCEPT_ENCODING'].to_s.include?(@headers['Content-Encoding'])
|
150
|
+
ResponseBank.log("uncompressing payload for client as client doesn't require encoding")
|
151
|
+
body = ResponseBank.decompress(body, @headers['Content-Encoding'])
|
152
|
+
@headers.delete('Content-Encoding')
|
153
|
+
end
|
154
|
+
else
|
155
|
+
ResponseBank.log("Cache hit, but missing content-encoding in the cache value headers, maybe because of 301 or 404 response or empty body string")
|
153
156
|
end
|
154
157
|
|
155
158
|
[status, @headers, [body]]
|
@@ -163,13 +166,19 @@ module ResponseBank
|
|
163
166
|
# If-None-Match: "abc"
|
164
167
|
# If-None-Match: W/"abc"
|
165
168
|
# If-None-Match: "abc", "def"
|
166
|
-
# If-None-Match:
|
169
|
+
# If-None-Match: *
|
167
170
|
return false unless entity_tag
|
168
171
|
return false unless if_none_match
|
169
172
|
|
173
|
+
return true if if_none_match == "*"
|
174
|
+
|
170
175
|
# strictly speaking an unquoted etag is not valid, yet common
|
171
176
|
# to avoid unintended greedy matches in we check for naked entity then includes with quoted entity values
|
172
|
-
|
177
|
+
entity_tag = %{"#{entity_tag}"} unless entity_tag.starts_with?('"')
|
178
|
+
|
179
|
+
if_none_match = %{"#{if_none_match}"} unless if_none_match.starts_with?('"') || if_none_match.starts_with?('W/"')
|
180
|
+
|
181
|
+
if_none_match == entity_tag || if_none_match.include?(entity_tag)
|
173
182
|
end
|
174
183
|
|
175
184
|
def stale_while_revalidate?(timestamp, cache_age_tolerance)
|
data/lib/response_bank.rb
CHANGED
@@ -64,7 +64,7 @@ module ResponseBank
|
|
64
64
|
key = %{#{key}:#{hash_value_str(data[:version])}} if data[:version]
|
65
65
|
|
66
66
|
# add the encoding to only the cache key but don't expose this detail in the entity_tag
|
67
|
-
key = %{#{key}:#{hash_value_str(data[:encoding])}} if data[:encoding]
|
67
|
+
key = %{#{key}:#{hash_value_str(data[:encoding])}} if data[:encoding]
|
68
68
|
|
69
69
|
key
|
70
70
|
when Array
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: response_bank
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tobias Lütke
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2023-04-
|
12
|
+
date: 2023-04-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: msgpack
|