Skip to content

Instantly share code, notes, and snippets.

@sr
Created July 21, 2009 20:02
Show Gist options
  • Save sr/151557 to your computer and use it in GitHub Desktop.
Save sr/151557 to your computer and use it in GitHub Desktop.
Client side caching for net/http using rack/client and rack/cache
require "rack/client"
require "rack/cache"
require "rack/test"
app = Rack::Builder.new {
use Rack::Cache,
:verbose => true,
:metastore => "heap:/",
:entitystore => "heap:/"
run Rack::Client
}
client = Rack::MockRequest.new(app)
2.times {
puts client.get("http://redbot.org/")["X-Rack-Cache"]
}
# outputs:
# miss, store
# fresh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment