Sha256: 505ab391813c22c0dbed1ac76eb8cbd8233d1cdc750192de3741abe2fd6bac39
Contents?: true
Size: 682 Bytes
Versions: 6
Compression:
Stored size: 682 Bytes
Contents
%w{ rack rack/utils }.each { |m| require m } module Murlsh # Rack middleware to force caches to always revalidate for urls that match # patterns. class MustRevalidate def initialize(app, options={}) @app = app @patterns = options[:patterns] ? [*options[:patterns]] : [] end def call(env) status, headers, body = @app.call(env) req = Rack::Request.new(env) headers = Rack::Utils::HeaderHash.new(headers) @patterns.each do |pattern| if pattern.match(req.path) headers['Cache-Control'] = 'must-revalidate, max-age=0' break end end [status, headers, body] end end end
Version data entries
6 entries across 6 versions & 1 rubygems