Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Cache-it-up!

  • Loading branch information...
commit 18099b99aac2ae89e9443658ac34dfdbbc8c6958 1 parent ff178b5
@fredwu authored
View
1  Gemfile
@@ -9,6 +9,7 @@ gem 'thin' # or mongrel
gem 'slim', '>= 0.8.3'
gem 'sqlite3-ruby', :require => 'sqlite3'
gem 'activerecord', '~> 3.0.3', :require => 'active_record'
+gem 'rack-cache', '~> 1.0', :require => 'rack/cache'
# Test requirements
gem 'rack-test', :group => :test, :require => 'rack/test'
View
3  Gemfile.lock
@@ -53,6 +53,8 @@ GEM
padrino-core (= 0.9.19)
polyglot (0.3.1)
rack (1.2.1)
+ rack-cache (1.0)
+ rack (>= 0.4)
rack-flash (0.1.1)
rack
rack-test (0.5.7)
@@ -84,6 +86,7 @@ PLATFORMS
DEPENDENCIES
activerecord (~> 3.0.3)
padrino (= 0.9.19)
+ rack-cache (~> 1.0)
rack-flash
rack-test
rake
View
12 app/app.rb
@@ -21,11 +21,13 @@ class RubyCommitters < Padrino::Application
##
# You can configure for a specified environment like:
#
- # configure :development do
- # set :foo, :bar
- # disable :asset_stamp # no asset timestamping for dev
- # end
- #
+ configure :production do
+ use Rack::Cache do
+ set :verbose, true
+ set :metastore, "file:cache/meta"
+ set :entitystore, "file:cache/body"
+ end
+ end
##
# You can manage errors like:
View
1  app/controllers/heroes.rb
@@ -2,6 +2,7 @@
get :index, :map => '/' do
@heroes = Hero.all
@attrs = %w{names nicks sites services books portraits}
+ response['Cache-Control'] = 'public, max-age=300'
render 'heroes/index'
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.