grape-cache_control 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +2 -0
- data/README.md +6 -0
- data/Rakefile +1 -1
- data/lib/grape/cache_control.rb +3 -2
- data/lib/grape/cache_control/version.rb +1 -1
- data/spec/unit/grape/cache_control_spec.rb +17 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df369824a78246d6fe3304d1df3b3fdf29b37772
|
4
|
+
data.tar.gz: 5a2b2a61b99c48192b29621e41e8949d1f8d70ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5403c032382bc8c7740bbc5813a36f5a97d5000098269cf6625cf3261478b453845545176b60ea346404996e5c556fb5e4f19c704f5fe5cc034f14931b3cce5f
|
7
|
+
data.tar.gz: a09a39428126304de3df5af07b39f2e040cf8af2de107bfb7e08b95967134093cc5a4241aff402b4fcfc2ef717991b5e9bb606edd296c6c021119cfd747a7d50
|
data/.rspec
ADDED
data/README.md
CHANGED
@@ -18,6 +18,12 @@ require 'grape/cache_control'
|
|
18
18
|
# Cache-Control:public,max-age=900
|
19
19
|
cache_control :public, max_age: 900
|
20
20
|
|
21
|
+
# Cache-Control:public,max-age=900,stale-while-revalidate=1600
|
22
|
+
cache_control :public, max_age: 900, stale_while_revalidate: 1600
|
23
|
+
|
24
|
+
# Cache-Control:public,max-age=900,stale-while-error=1600
|
25
|
+
cache_control :public, max_age: 900, stale_while_error: 1600
|
26
|
+
|
21
27
|
# Cache-Control:public,no-store,max-age=900,s-maxage=86400
|
22
28
|
cache_control :public, :no_store, max_age: 900, s_maxage:86400
|
23
29
|
|
data/Rakefile
CHANGED
data/lib/grape/cache_control.rb
CHANGED
@@ -9,8 +9,9 @@ module Grape
|
|
9
9
|
CACHE_CONTROL = 'Cache-Control'.freeze
|
10
10
|
EXPIRES = 'Expires'.freeze
|
11
11
|
TRUE = 'true'.freeze
|
12
|
-
SETTABLE_DIRECTIVES = [:max_age, :s_maxage].freeze
|
13
|
-
TRUTHY_DIRECTIVES = [:public, :private, :no_cache, :no_store, :no_transform,
|
12
|
+
SETTABLE_DIRECTIVES = [:max_age, :s_maxage, :stale_while_revalidate, :stale_while_error].freeze
|
13
|
+
TRUTHY_DIRECTIVES = [:public, :private, :no_cache, :no_store, :no_transform,
|
14
|
+
:must_revalidate, :proxy_revalidate].freeze
|
14
15
|
ALL_DIRECTIVES = (TRUTHY_DIRECTIVES | SETTABLE_DIRECTIVES).freeze
|
15
16
|
|
16
17
|
ALL_DIRECTIVES.each do |d|
|
@@ -66,6 +66,23 @@ describe Grape::CacheControl do
|
|
66
66
|
expect(last_response.headers['Cache-Control'].split(', ')).to include('public', 'max-age=60')
|
67
67
|
end
|
68
68
|
|
69
|
+
it 'supports stale-while-revalidate' do
|
70
|
+
subject.get('/stale_blueberries') do
|
71
|
+
cache_control :public, stale_while_revalidate: 120
|
72
|
+
end
|
73
|
+
|
74
|
+
get 'stale_blueberries'
|
75
|
+
expect(last_response.headers['Cache-Control'].split(', ')).to include('public', 'stale-while-revalidate=120')
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'supports stale-while-error' do
|
79
|
+
subject.get('/error_blueberries') do
|
80
|
+
cache_control :public, stale_while_error: 120
|
81
|
+
end
|
82
|
+
|
83
|
+
get 'error_blueberries'
|
84
|
+
expect(last_response.headers['Cache-Control'].split(', ')).to include('public', 'stale-while-error=120')
|
85
|
+
end
|
69
86
|
end
|
70
87
|
|
71
88
|
describe 'expires' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grape-cache_control
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Karl Freeman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: grape
|
@@ -117,6 +117,7 @@ extra_rdoc_files: []
|
|
117
117
|
files:
|
118
118
|
- ".document"
|
119
119
|
- ".gitignore"
|
120
|
+
- ".rspec"
|
120
121
|
- ".rubocop.yml"
|
121
122
|
- ".travis.yml"
|
122
123
|
- ".yardopts"
|
@@ -157,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
158
|
version: '0'
|
158
159
|
requirements: []
|
159
160
|
rubyforge_project:
|
160
|
-
rubygems_version: 2.
|
161
|
+
rubygems_version: 2.4.5
|
161
162
|
signing_key:
|
162
163
|
specification_version: 4
|
163
164
|
summary: Cache-Control and Expires helpers for Grape
|
@@ -168,3 +169,4 @@ test_files:
|
|
168
169
|
- spec/support/rack-test.rb
|
169
170
|
- spec/support/timecop.rb
|
170
171
|
- spec/unit/grape/cache_control_spec.rb
|
172
|
+
has_rdoc:
|