rack-nocache 0.1.0

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.
Files changed (3) hide show
  1. data/lib/rack-nocache.rb +1 -0
  2. data/lib/rack/nocache.rb +27 -0
  3. metadata +56 -0
@@ -0,0 +1 @@
1
+ require "rack/nocache"
@@ -0,0 +1,27 @@
1
+ module Rack
2
+ class Nocache
3
+ def initialize(app)
4
+ @app = app
5
+ end
6
+
7
+ def call(env)
8
+ status, headers, body = @app.call(patch_request_headers(env))
9
+ [status, patch_response_headers(headers), body]
10
+ end
11
+
12
+ protected
13
+ CACHE_BUSTER = {
14
+ "Cache-Control" => "no-cache, no-store, max-age=0, must-revalidate",
15
+ "Pragma" => "no-cache",
16
+ "Expires" => "Fri, 29 Aug 1997 02:14:00 EST"
17
+ }
18
+
19
+ def patch_request_headers(env)
20
+ env.reject{|k,v| k =~ /^HTTP_IF/i }
21
+ end
22
+
23
+ def patch_response_headers(env)
24
+ env.reject{|k,v| k =~ /^ETag$/i }.merge(CACHE_BUSTER)
25
+ end
26
+ end
27
+ end
metadata ADDED
@@ -0,0 +1,56 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rack-nocache
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Tom Lea
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-02-11 00:00:00 +00:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email: contrib@tomlea.co.uk
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - lib/rack/nocache.rb
26
+ - lib/rack-nocache.rb
27
+ has_rdoc: true
28
+ homepage: http://tomlea.co.uk
29
+ licenses: []
30
+
31
+ post_install_message:
32
+ rdoc_options: []
33
+
34
+ require_paths:
35
+ - lib
36
+ required_ruby_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: "0"
41
+ version:
42
+ required_rubygems_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: "0"
47
+ version:
48
+ requirements: []
49
+
50
+ rubyforge_project:
51
+ rubygems_version: 1.3.5
52
+ signing_key:
53
+ specification_version: 3
54
+ summary: Rack::Nocache ensures all requests are uncached
55
+ test_files: []
56
+