https://github.com/masylum/rack-staticifier
Staticly cache requests to any Rack application - perfect for creating static sites/blogs/etc!
https://github.com/masylum/rack-staticifier
Last synced: 10 months ago
JSON representation
Staticly cache requests to any Rack application - perfect for creating static sites/blogs/etc!
- Host: GitHub
- URL: https://github.com/masylum/rack-staticifier
- Owner: masylum
- Created: 2013-12-27T10:29:02.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2013-12-27T10:30:47.000Z (over 12 years ago)
- Last Synced: 2025-08-23T00:53:06.126Z (11 months ago)
- Language: Ruby
- Homepage:
- Size: 120 KB
- Stars: 0
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.rdoc
Awesome Lists containing this 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?