rack-cache-buster 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,14 +6,39 @@ Limits the max-age to the contents of the `WIND_DOWN` file, and salts the ETags
6
6
 
7
7
  ## Usage:
8
8
  require "rack/cache_buster"
9
- WIND_DOWN_TIME = Time.parse(File.read(File.join(Rails.root, "WIND_DOWN"))) rescue nil
10
- APP_VERSION = File.read(File.join(Rails.root, "REVISION")) rescue nil
11
-
12
9
 
13
-
14
10
  use Rack::CacheBuster, APP_VERSION, WIND_DOWN_TIME
15
11
 
16
- ### Before you deploy:
12
+
13
+ ## Rails Usage:
14
+ require "rack/cache_buster"
15
+
16
+ use Rack::CacheBuster::Rails
17
+
18
+ ### Before you deploy (capistrano):
19
+
20
+ Add this to your `deploy.rb`:
21
+
22
+ begin
23
+ gem "rack-cache-buster"
24
+ require 'rack_cache_buster_recipes'
25
+ rescue LoadError
26
+ puts "\n\n*** Please gem install rack-cache-buster before trying to deploy.\n\n"
27
+ end
28
+
29
+ # set :wind_down_time, 60*60 # defaults to 1hr
30
+
31
+ Then:
32
+
33
+ cap cache:winddown
34
+
35
+ … wait 1 hr …
36
+
37
+ cap deploy:migrations
38
+
39
+ … profit!
40
+
41
+ ### Before you deploy (other):
17
42
 
18
43
  * Find the maximum cache duration for all pages in your app, start this process with at least that amount time before you deploy.
19
44
 
@@ -35,7 +35,7 @@ module Rack
35
35
 
36
36
  def unpatch_etag(headers)
37
37
  ETAGGY_HEADERS.inject(headers){|memo, k|
38
- memo.has_key?(k) ? memo.merge(k => strip_etag(memo[k])) : memo
38
+ memo[k] ? memo.merge(k => strip_etag(memo[k])) : memo
39
39
  }
40
40
  end
41
41
 
@@ -27,6 +27,20 @@ class CacheBustingTest < IntegrationTest
27
27
  end
28
28
  end
29
29
 
30
+ should "no explode when etagy header is given but nil" do
31
+ given_env = nil
32
+
33
+ @app = Rack::CacheBuster.new(lambda { |env| given_env = env; [200, {}, []] }, "foo", Time.now)
34
+
35
+ headers = {}
36
+ Rack::CacheBuster::ETAGGY_HEADERS.each do |k|
37
+ headers[k] = nil
38
+ end
39
+
40
+ @app.call(headers)
41
+
42
+ end
43
+
30
44
  should "set max-age to 0 if we should already have expired" do
31
45
  @app = Rack::CacheBuster.new(CACHEY_APP, nil, Time.now - 100)
32
46
  get "/foooo"
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-cache-buster
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ hash: 19
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 2
9
+ - 2
10
+ version: 0.2.2
5
11
  platform: ruby
6
12
  authors:
7
13
  - Tom Lea
@@ -9,7 +15,7 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2009-10-26 00:00:00 +00:00
18
+ date: 2011-03-07 00:00:00 +00:00
13
19
  default_executable:
14
20
  dependencies: []
15
21
 
@@ -41,21 +47,27 @@ require_paths:
41
47
  - recipes
42
48
  - lib
43
49
  required_ruby_version: !ruby/object:Gem::Requirement
50
+ none: false
44
51
  requirements:
45
52
  - - ">="
46
53
  - !ruby/object:Gem::Version
54
+ hash: 3
55
+ segments:
56
+ - 0
47
57
  version: "0"
48
- version:
49
58
  required_rubygems_version: !ruby/object:Gem::Requirement
59
+ none: false
50
60
  requirements:
51
61
  - - ">="
52
62
  - !ruby/object:Gem::Version
63
+ hash: 3
64
+ segments:
65
+ - 0
53
66
  version: "0"
54
- version:
55
67
  requirements: []
56
68
 
57
69
  rubyforge_project: rack-cache-buster
58
- rubygems_version: 1.3.5
70
+ rubygems_version: 1.5.0
59
71
  signing_key:
60
72
  specification_version: 3
61
73
  summary: Place this in your rack stack and all caching will be gone.