Rack::Cache is suitable as a quick, drop-in component to enable HTTP caching for Rack-enabled applications that produce freshness (Expires, +Cache-Control+) and/or validation (+Last-Modified+, ETag) information.
Create with default options:
require 'rack/cache' Rack::Cache.new(app, :verbose => true, :entitystore => 'file:cache')
Within a rackup file (or with Rack::Builder):
require 'rack/cache'
use Rack::Cache do
set :verbose, true
set :metastore, 'memcached://localhost:11211/meta'
set :entitystore, 'file:/var/cache/rack'
end
run app
| MEMCACHED | = | MEMCACHE |
| GAECACHE | = | GAEStore |
| GAE | = | GAEStore |
| MEMCACHED | = | MEMCACHE |
| GAECACHE | = | GAEStore |
| GAE | = | GAEStore |
Create a new Rack::Cache middleware component that fetches resources from the specified backend application. The options Hash can be used to specify default configuration values (see attributes defined in Rack::Cache::Options for possible key/values). When a block is given, it is executed within the context of the newly create Rack::Cache::Context object.
# File lib/rack/cache.rb, line 42
42: def self.new(backend, options={}, &b)
43: Context.new(backend, options, &b)
44: end