Class: Mongrel::PageCacheHandler::Cacher

Inherits:
HttpHandler
  • Object
show all
Defined in:
lib/cacher.rb

Instance Method Summary collapse

Instance Method Details

#process(request, response) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/cacher.rb', line 7

def process(request, response)
  Mongrel::PageCacheHandler::Utils.do_work(request, response) do
    if response.status == 200
      sent = response.header.instance_variable_get("@sent")
      mcm = sent["mongrel_cache_me"]
      imcm = (sent["ignore_mongrel_cache_me"] || false)
      if mcm && !imcm
        # file_path = Mongrel::PageCacheHandler::Utils.build_full_file_path(request, true)
        file_path = Mongrel::PageCacheHandler::Utils.build_cachetastic_key(request)
        puts "Let's cache this page: #{file_path} to the cache"
        Cachetastic::Caches::PageCache.set(file_path, response.body.string)
     end
    end
  end
end