Module: Rack::Cache
- Defined in:
- lib/rack/cache.rb,
lib/rack/cache/core.rb,
lib/rack/cache/config.rb,
lib/rack/cache/context.rb,
lib/rack/cache/headers.rb,
lib/rack/cache/options.rb,
lib/rack/cache/request.rb,
lib/rack/cache/storage.rb,
lib/rack/cache/response.rb,
lib/rack/cache/metastore.rb,
lib/rack/cache/entitystore.rb
Overview
HTTP Caching For Rack
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.
-
Standards-based (RFC 2616 compliance)
-
Freshness/expiration based caching and validation
-
Supports HTTP Vary
-
Portable: 100% Ruby / works with any Rack-enabled framework
-
VCL-like configuration language for advanced caching policies
-
Disk, memcached, and heap memory storage backends
Usage
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
Defined Under Namespace
Modules: Config, Core, Headers, Options, RequestHeaders, ResponseHeaders Classes: Context, EntityStore, IllegalTransition, MetaStore, Request, Response, Storage
Class Method Summary collapse
-
.new(backend, options = {}, &b) ⇒ Object
Create a new Rack::Cache middleware component that fetches resources from the specified backend application.
Class Method Details
.new(backend, options = {}, &b) ⇒ Object
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.
48 49 50 |
# File 'lib/rack/cache.rb', line 48 def self.new(backend, ={}, &b) Context.new(backend, , &b) end |