no_cache_control 0.0.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 32fa5cac25962a36d50c719cef18fedc6d9c03e2
4
+ data.tar.gz: 9a90ec98a71607b9f92aadbd2b79acccd7aa82e2
5
+ SHA512:
6
+ metadata.gz: 727f4dc910b5253d691b8617ce8b40deeaa0f9c7f629acb0217b4bcbbebb20b3aba47221b3f908009378ba9c115edb5097ff4a80b55ade811c2441e1a36da283
7
+ data.tar.gz: 3e211809f7063a3f55e55de74266f7761f14abdeb97fef2bf7a377a20535bd13d61e682b8f8d9a55036f1edc3a357a23ff14f6903d768f06cdafd999e96ff7f4
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in no_cache_control.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Tomas Valent
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,50 @@
1
+ # NoCacheControl
2
+
3
+ If you're building paranoid software where security must be
4
+ bullet-proof, one concern is that Authenticated pages **should
5
+ not be browser cached**.
6
+
7
+ This is due to fact that even when user is logged out, someone
8
+ may sit at his competer and click browser back button and see the
9
+ restricted data.
10
+
11
+ Gem will set these headers:
12
+
13
+ ```
14
+ Cache-Control: no-cache, no-store, max-age=0, must-revalidate
15
+ Pragma: no-cache
16
+ Expires: -1
17
+ ```
18
+
19
+ If you are building next-gen Twitter app than this is a bad idea
20
+ because you want to cache as much as possible. But when you're
21
+ building comertial Dashboards, payment software, ... than you
22
+ must do this.
23
+
24
+ ## Installation
25
+
26
+ Add this line to your application's Gemfile:
27
+
28
+ ```ruby
29
+ gem 'no_cache_control', github: equivalent/no_cache_control
30
+ ```
31
+
32
+ And then execute:
33
+
34
+ $ bundle
35
+
36
+ Or install it yourself as:
37
+
38
+ $ gem install no_cache_control
39
+
40
+ ## Usage
41
+
42
+ * whitelisting of controllers that should be cached
43
+
44
+ ## Contributing
45
+
46
+ 1. Fork it ( https://github.com/[my-github-username]/no_cache_control/fork )
47
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
48
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
49
+ 4. Push to the branch (`git push origin my-new-feature`)
50
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,21 @@
1
+ require "no_cache_control/version"
2
+
3
+ module NoCacheControl
4
+ def self.included(base)
5
+ begin
6
+ base.before_action :set_no_cache_control
7
+ rescue NoMethodError
8
+ base.before_filter :set_no_cache_control
9
+ end
10
+ end
11
+
12
+ def set_no_cache_control
13
+ response.headers["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate"
14
+
15
+ # Pragma and Expires are not a true header defined in RFC, however some browsers accepts them
16
+ response.headers["Pragma"] = "no-cache"
17
+ response.headers["Expires"] = '-1'
18
+ end
19
+ end
20
+
21
+ ActionController::Base.send(:include, NoCacheControl)
@@ -0,0 +1,3 @@
1
+ module NoCacheControl
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'no_cache_control/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "no_cache_control"
8
+ spec.version = NoCacheControl::VERSION
9
+ spec.authors = ["Tomas Valent"]
10
+ spec.email = ["equivalent@eq8.eu"]
11
+ spec.summary = %q{ Sets Cache-Control to no-cache no-store on Rails app }
12
+ spec.description = "Sets browser caching headers on Rails app so that " +
13
+ "browser caching of pages will be disabled. " +
14
+ "This is achived by setting Cache-Control to no-cache no-store " +
15
+ "+ Pragma header no-cache and Expires header to -1"
16
+ spec.homepage = "https://github.com/equivalent/no_cache_control"
17
+ spec.license = "MIT"
18
+
19
+ spec.files = `git ls-files -z`.split("\x0")
20
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
21
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.7"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: no_cache_control
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Tomas Valent
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: Sets browser caching headers on Rails app so that browser caching of
42
+ pages will be disabled. This is achived by setting Cache-Control to no-cache no-store
43
+ + Pragma header no-cache and Expires header to -1
44
+ email:
45
+ - equivalent@eq8.eu
46
+ executables: []
47
+ extensions: []
48
+ extra_rdoc_files: []
49
+ files:
50
+ - ".gitignore"
51
+ - Gemfile
52
+ - LICENSE.txt
53
+ - README.md
54
+ - Rakefile
55
+ - lib/no_cache_control.rb
56
+ - lib/no_cache_control/version.rb
57
+ - no_cache_control.gemspec
58
+ homepage: https://github.com/equivalent/no_cache_control
59
+ licenses:
60
+ - MIT
61
+ metadata: {}
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 2.2.2
79
+ signing_key:
80
+ specification_version: 4
81
+ summary: Sets Cache-Control to no-cache no-store on Rails app
82
+ test_files: []