Skip to content
This repository was archived by the owner on Dec 3, 2019. It is now read-only.

Commit 18b4310

Browse files
committed
Recently cached responses are cached correctly. Closes issue #11
1 parent 0a16e82 commit 18b4310

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
# 0.1.20 (2015-05-01)
4+
5+
* Recently cached responses are cached correctly. Fixes issue #11
6+
37
# 0.1.19 (2015-05-01)
48

59
* The 'max-stale' header doesn't affect 'max-age' validation

cache_rules.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require 'date'
66

77
Gem::Specification.new do |s|
88
s.name = 'cache_rules'
9-
s.version = '0.1.19'
9+
s.version = '0.1.20'
1010

1111
s.date = Date.today.to_s
1212

lib/helpers.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ def helper_heuristic(now, cached, current_age)
295295

296296
# Don't cache heuristic responses more than 24 hours old, and avoid sending a 113 Warning ;)
297297
# source: https://tools.ietf.org/html/rfc7234#section-4.2.2
298-
current_age > 86400 ? 0 : result
298+
current_age > 86400 ? 0 : (now + result)
299299
else
300300
0
301301
end

test/test_helpers.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ def test_heuristic
362362
too_old = CacheRules.helper_heuristic now, @cached_headers, 86401
363363
noop = CacheRules.helper_heuristic(now, {}, 42)
364364

365-
assert_equal last_modified, 16560
365+
assert_equal last_modified, 1420378785
366366
assert_equal not_public, 0
367367
assert_equal too_old, 0
368368
assert_equal noop, 0

0 commit comments

Comments
 (0)