Class: Imagery::CachePurge

Inherits:
Object
  • Object
show all
Defined in:
lib/imagery/middleware/cache_purge.rb

Constant Summary

Success =
[200, {'Content-Type' => 'text/plain'}, ['OK']]

Instance Method Summary (collapse)

Constructor Details

- (CachePurge) initialize(app)

A new instance of CachePurge



5
6
7
# File 'lib/imagery/middleware/cache_purge.rb', line 5

def initialize(app)
  @app = app
end

Instance Method Details

- (Object) call(env)

PURGE /s/files/1/0001/4168/files/thumbs/pic_thumb.jpg?12428536032 HTTP/1.0



11
12
13
14
15
16
17
18
19
# File 'lib/imagery/middleware/cache_purge.rb', line 11

def call(env)
  # Rack cache automatically invalidates resource if the verbs are not GET/POST so
  # we don't actually have to do anything. Simply don't delegate those to the backend
  if env['REQUEST_METHOD'] == 'PURGE'
    Success
  else
    @app.call(env)
  end
end