response_bank 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7d25739f9bd846e1cd3364a422cc90590b32fcb5f7e56cd307af0e83f0d5ddac
4
- data.tar.gz: 14c1a7f96abcc45025cee9f998342fb6185779774dc72986ebb1a5bbcb96c413
3
+ metadata.gz: 87b964dde00b2a9aa0b319430185a6cfefa8d40323b634556cf1298c8e2ee1a9
4
+ data.tar.gz: 16b9d49921f037bec53031f145e44815a820de2ec93992a6d6c4926cb22b2f95
5
5
  SHA512:
6
- metadata.gz: b6120bc7a707fa5ddd1cd3a143e40681e375864b075fe0e74b1128cc4ee460690400a70c47599772addba8d2bee56b02ce14a820c5e4af376f0eaa154f1fe88c
7
- data.tar.gz: 5ae1545f2c40d7abbf06b8ba43c8d353cb171fc97ce667fa280c5f991c37f7e514c7673898a99242e446f9975ef22f4cb91eaa053165664a9c309fa4d6b39197
6
+ metadata.gz: 1f95e92a493db39dd4cb3dc43dd5582d19e64a9857f3304420152ae235088f1d1101cc480d112c9f49346c08e168eaaf881e351061f0ac17d6676a452ca4dc06
7
+ data.tar.gz: b77dfa70dc32d45153c2177e9e5c4762a881d7bd998479b8a209121b903ef9d3f323335ebba7aeb6bbfab381fd5fbddc2f861ddf19145e606348d8b5b00a60e7
@@ -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
- # if a cache key hit and client doesn't match encoding, return the raw body
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')
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]]
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module ResponseBank
3
- VERSION = "1.3.0"
3
+ VERSION = "1.3.1"
4
4
  end
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] && data[:encoding] != "gzip"
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.0
4
+ version: 1.3.1
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-04 00:00:00.000000000 Z
12
+ date: 2023-04-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: msgpack