Class: Mongrel::PageCacheHandler::CacheServer

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

Instance Method Summary collapse

Instance Method Details

#process(request, response) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/cache_server.rb', line 6

def process(request, response)
  Mongrel::PageCacheHandler::Utils.do_work(request, response) do
    file_path = Mongrel::PageCacheHandler::Utils.build_cachetastic_key(request)
    f = Cachetastic::Caches::PageCache.get(file_path)
    if f
      puts "We found: #{file_path} in the cache, let's render it"
      response.start(200, true) do |head, out|
        head["Content-Type"] = "text/html"
        out.write(f)
      end
    end
  end
end