Rack::Staticifier - Rack middleware for static caching

To view this screencast, add it to your cart and checkout. You can buy this screencast for any price, including FREE!

While at RailsConf this year, I got bored and coded up a Rack middleware for static caching.

Rails has a way to staticly cache pages built-in but not all Ruby web frameworks do, so I figured this would make a good piece of middleware.

( Also, I knew that I wanted to create Staticify and it would require Rack::Staticifier )

 1 # this will cache ALL responses in a 'cache' directory
 2 use Rack::Staticifier
 3 
 4 # this will cache ALL responses in a 'public/my/cached/stuff' directory
 5 use Rack::Staticifier, :root => 'public/my/cached/stuff'
 6 
 7 # this will only cache requests with 'foo' in the URL
 8 use Rack::Staticifier do |env, response|
 9   env['PATH_INFO'].include?('foo')
10 end

http://github.com/remi/rack-staticifier