Permalink
Browse files

Merge branch 'force-pass' of https://github.com/tekwiz/rack-cache

  • Loading branch information...
2 parents 0d7ce26 + 6943584 commit 39f5bae5a1fb8435904b3bd5ba134d8a5e71672e @rtomayko committed Sep 11, 2011
Showing with 18 additions and 1 deletion.
  1. +7 −0 doc/faq.markdown
  2. +1 −1 lib/rack/cache/context.rb
  3. +10 −0 test/context_test.rb
View
@@ -110,6 +110,13 @@ frameworks are based entirely on manual purge and do not support validation at
the cache level.
+<a class='hash' id='force-pass' href='#force-pass'>#</a>
+
+### Q: How do I bypass rack-cache on a per-request basis?
+
+Set the `rack-cache.force-pass` variable in the rack environment to `true`.
+
+
<a class='hash' id='efficient-validation' href='#efficient-validation'>#</a>
### Q: What does "Efficient Validation" mean?
@@ -61,7 +61,7 @@ def call!(env)
response =
if @request.get? || @request.head?
- if !@env['HTTP_EXPECT']
+ if !@env['HTTP_EXPECT'] and !@env['rack-cache.force-pass']
lookup
else
pass
View
@@ -15,6 +15,16 @@
response.headers.should.not.include 'Age'
end
+ it 'passes on rack-cache.force-pass' do
+ respond_with 200
+ get '/', {"rack-cache.force-pass" => true}
+
+ app.should.be.called
+ response.should.be.ok
+ cache.trace.should == [:pass]
+ response.headers.should.not.include 'Age'
+ end
+
%w[post put delete].each do |request_method|
it "invalidates on #{request_method} requests" do
respond_with 200

0 comments on commit 39f5bae

Please sign in to comment.