diff options
author | Santiago Pastorino <santiago@wyeworks.com> | 2012-10-01 19:52:52 -0700 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2012-10-01 19:52:52 -0700 |
commit | 037e50ec39c7c3d58a102a6584e2740652420d1d (patch) | |
tree | 17dfc52c9192db2cf6b79a77df7a15260527fa4c /railties/lib | |
parent | f934aecf61cd2c5df8a598fbddc83516f92d96c0 (diff) | |
parent | f4a6f1d3f0d7ec2eb7a779a74f587cb953992ea8 (diff) | |
download | rails-037e50ec39c7c3d58a102a6584e2740652420d1d.tar.gz rails-037e50ec39c7c3d58a102a6584e2740652420d1d.tar.bz2 rails-037e50ec39c7c3d58a102a6584e2740652420d1d.zip |
Merge pull request #7794 from guilleiguaran/extract-rack-cache
Use Rack::Cache middleware only if is in Gemfile
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/rails/application.rb | 6 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/app/templates/Gemfile | 4 |
2 files changed, 10 insertions, 0 deletions
diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index 050190cba6..0b9ed025db 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -282,6 +282,12 @@ module Rails ActionDispatch::MiddlewareStack.new.tap do |middleware| app = self if rack_cache = config.action_controller.perform_caching && config.action_dispatch.rack_cache + begin + require 'rack/cache' + rescue LoadError => error + error.message << ' Be sure to add rack-cache to your Gemfile' + raise + end require "action_dispatch/http/rack_cache" middleware.use ::Rack::Cache, rack_cache end diff --git a/railties/lib/rails/generators/rails/app/templates/Gemfile b/railties/lib/rails/generators/rails/app/templates/Gemfile index 55a6b3f4f2..69027f2903 100644 --- a/railties/lib/rails/generators/rails/app/templates/Gemfile +++ b/railties/lib/rails/generators/rails/app/templates/Gemfile @@ -9,6 +9,10 @@ source 'https://rubygems.org' <%= assets_gemfile_entry %> <%= javascript_gemfile_entry %> +# Puts a simple HTTP cache in front of your app. +# For large-scale production use, consider using a caching reverse proxy like nginx, varnish, or squid. +gem 'rack-cache', '~> 1.2' + # To use ActiveModel has_secure_password # gem 'bcrypt-ruby', '~> 3.0.0' |