Skip to content

Instantly share code, notes, and snippets.

@kyontan
Created December 23, 2013 09:58
Show Gist options
  • Save kyontan/8094373 to your computer and use it in GitHub Desktop.
Save kyontan/8094373 to your computer and use it in GitHub Desktop.
Using rack-cache on Sinatra
require "rubygems"
require "bundler"
get "/foo" do
cache_control :public, max_age: 1800 # 1800 sec = 30 mins.
"Hello world"
end
require 'bundler'
Bundler.require
require_relative 'app'
use Rack::Cache,
verbose: true,
metastore: 'file:/path/to/cache/meta',
entitystore: 'file:/path/to/cache/body'
# metastore: "memcached://#{memcache_servers}",
# entitystore: "memcached://#{memcache_servers}"
run Sinatra::Application
gem "rack-cache", require: "rack/cache"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment