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

Commit

Permalink
Ensure Cache-Control is verified
Browse files Browse the repository at this point in the history
  • Loading branch information
aw committed Apr 28, 2015
1 parent 24094d3 commit 7545c40
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.1.14 (2015-04-28)

* Ensure Cache-Control is verified

## 0.1.13 (2015-04-28)

* Don't cache the Host header
Expand Down
2 changes: 1 addition & 1 deletion cache_rules.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require 'date'

Gem::Specification.new do |s|
s.name = 'cache_rules'
s.version = '0.1.13'
s.version = '0.1.14'

s.date = Date.today.to_s

Expand Down
12 changes: 7 additions & 5 deletions lib/validations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,13 @@ def validate_no_cache?(headers)

# source: https://tools.ietf.org/html/rfc7234#section-5.2.2.2
# source: https://tools.ietf.org/html/rfc7234#section-3.2
return 1 if (( cached = cached_headers['Cache-Control'] )) &&
helper_no_cache.call(cached_headers) ||
(cached['no-cache'] && cached['no-cache']['quoted_string'].nil?) ||
(cached['s-maxage'] && cached['s-maxage']['token'].to_s == "0") ||
(cached['max-age'] && cached['max-age']['token'].to_s == "0")
if cached_headers['Cache-Control']
return 1 if (( cached = cached_headers['Cache-Control'] )) &&
helper_no_cache.call(cached_headers) ||
(cached['no-cache'] && cached['no-cache']['quoted_string'].nil?) ||
(cached['s-maxage'] && cached['s-maxage']['token'].to_s == "0") ||
(cached['max-age'] && cached['max-age']['token'].to_s == "0")
end

# source: https://tools.ietf.org/html/rfc7234#section-5.4
# Legacy support for HTTP/1.0 Pragma header
Expand Down

0 comments on commit 7545c40

Please sign in to comment.