class Rack::WWWhisper::NoPublicCache
An internal middleware used by Rack::WWWhisper
to change directives that enable public caching into directives that enable private caching.
To be on a safe side, all wwwhisper protected content is treated as sensitive and not publicly cacheable.
Public Class Methods
new(app)
click to toggle source
# File lib/rack/wwwhisper.rb, line 292 def initialize(app) @app = app end
Public Instance Methods
call(env)
click to toggle source
If a response enables caching, makes sure it is private.
# File lib/rack/wwwhisper.rb, line 297 def call(env) status, headers, body = @app.call(env) if cache_control = headers['Cache-Control'] cache_control = cache_control.gsub(/public/, 'private') if (not cache_control.include? 'private' and cache_control.index(/max-age\s*=\s*0*[1-9]/)) # max-age > 0 without 'public' or 'private' directive is # treated as 'public', so 'private' needs to be prepended. cache_control.insert(0, 'private, ') end headers['Cache-Control'] = cache_control end [status, headers, body] end