Rack::Cache is suitable as a quick drop-in component to enable HTTP caching for Rack-based applications that produce freshness (Expires, Cache-Control) and/or validation (Last-Modified, ETag) information.

News

Installation

$ sudo gem install rack-cache

Or, from a local working copy:

$ git clone git://github.com/rtomayko/rack-cache.git
$ rake package && sudo rake install

Basic Usage

Rack::Cache is implemented as a piece of Rack middleware and can be used with any Rack-based application. If your application includes a rackup (.ru) file or uses Rack::Builder to construct the application pipeline, simply require and use as follows:

require 'rack/cache'

use Rack::Cache,
  :verbose     => true,
  :metastore   => 'file:/var/cache/rack/meta',
  :entitystore => 'file:/var/cache/rack/body'

run app

Assuming you’ve designed your backend application to take advantage of HTTP’s caching features, no further code or configuration is required for basic caching.

More

See Also

The overall design of Rack::Cache is based largely on the work of the internet standards community. The following resources provide a good starting point for exploring the basic concepts of HTTP caching:

Rack::Cache takes (liberally) various concepts from Varnish and Django’s cache framework.

License

Rack::Cache is Copyright © 2008 by Ryan Tomayko and is provided under the MIT license