Class: Rack::NonCache::Engine
- Inherits:
-
Object
- Object
- Rack::NonCache::Engine
- Defined in:
- lib/rack/noncache/engine.rb
Instance Attribute Summary collapse
-
#blacklist ⇒ Object
Returns the value of attribute blacklist.
-
#whitelist ⇒ Object
Returns the value of attribute whitelist.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(backend, options) {|_self| ... } ⇒ Engine
constructor
A new instance of Engine.
Constructor Details
#initialize(backend, options) {|_self| ... } ⇒ Engine
Returns a new instance of Engine.
7 8 9 10 11 12 |
# File 'lib/rack/noncache/engine.rb', line 7 def initialize(backend, ) @backend = backend whitelist = [:whitelist] blacklist = [:blacklist] yield self if block_given? end |
Instance Attribute Details
#blacklist ⇒ Object
Returns the value of attribute blacklist.
5 6 7 |
# File 'lib/rack/noncache/engine.rb', line 5 def blacklist @blacklist end |
#whitelist ⇒ Object
Returns the value of attribute whitelist.
5 6 7 |
# File 'lib/rack/noncache/engine.rb', line 5 def whitelist @whitelist end |
Instance Method Details
#call(env) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rack/noncache/engine.rb', line 14 def call(env) # execute the request using our backend status, headers, response = @backend.call(env) if target_path? env['REQUEST_URI'] headers['HTTP_CACHE_CONTROL'] = 'no-cache, max-age=0, must-revalidate, no-store, private, ' # Set standard HTTP/1.0 no-cache header. headers['HTTP_CACHE_CONTROL'] += 'max-stale=0, post-check=0, pre-check=0, ' + 'no-cache=\"Set-Cookie, Set-Cookie2\"' # Set standard HTTP/1.1 no-cache header. headers['HTTP_PRAGMA'] = 'no-cache' # Set to expire far in the past. Prevents caching at the proxy server headers['HTTP_EXPIRES'] = Time.now.httpdate # Deprecated header headers['HTTP_KEEP_ALIVE'] = 'timeout=3, max=993' headers['X-Content-Type-Options'] = 'nosniff' end [status, headers, response] end |