No commit activity in last 3 years
No release in over 3 years
Staticly cache requests to any Rack application - perfect for creating static sites/blogs/etc!
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

Rack::Staticifier¶ ↑

Rack::Staticifier is Rack middleware for staticly caching responses.

Install¶ ↑

$ gem sources -a http://gems.github.com
$ sudo gem install remi-rack-staticifier

Usage¶ ↑

require 'rack/staticifier'

# this will cache ALL responses in a 'cache' directory
use Rack::Staticifier

# this will cache ALL responses in a 'public/my/cached/stuff' directory
use Rack::Staticifier, :root => 'public/my/cached/stuff'

# this will only cache requests with 'foo' in the URL
use Rack::Staticifier do |env, response|
  env['PATH_INFO'].include?('foo')
end

# this will only cache requests with 'hi' in the response body
use Rack::Staticifier do |env, response|
  # response is a regular Rack response, eg. [200, {}, ['hi there']]
  body = ''
  response.last.each {|string| body << string }
  body.include?('hi')
end

# this will only cache requests with 'foo' in the URL (incase you don't want to pass a block)
use Rack::Staticifier, :cache_if => lambda { |env, response| env['PATH_INFO'].include?('foo') }

TODO¶ ↑

  • compare to Rack::ResponseCache (in rack-contrib) … maybe that can replace this, or vice-versa?