Class: Rack::CacheBuster

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/cache_buster.rb

Direct Known Subclasses

Rails

Defined Under Namespace

Classes: CacheControlHeader, Rails

Instance Method Summary collapse

Constructor Details

#initialize(app, key, target_time = nil) ⇒ CacheBuster

Returns a new instance of CacheBuster.



5
6
7
8
9
# File 'lib/rack/cache_buster.rb', line 5

def initialize(app, key, target_time = nil)
  @app, @target_time = app, target_time
  @key = "-"+Digest::MD5.hexdigest(key || "blank-key").freeze
  @key_regexp = /#{@key}/.freeze
end

Instance Method Details

#call(env) ⇒ Object



11
12
13
14
# File 'lib/rack/cache_buster.rb', line 11

def call(env)
  status, headers, body = app.call(unpatch_etag(env))
  [status, patch_etag(limit_cache(headers)), body]
end