mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
config.action_dispatch.rack_cache should set explicitly to enable Rack::Cache
This commit is contained in:
parent
4b33bbc803
commit
586a991830
4 changed files with 25 additions and 7 deletions
|
@ -12,12 +12,7 @@ module ActionDispatch
|
||||||
config.action_dispatch.rescue_templates = { }
|
config.action_dispatch.rescue_templates = { }
|
||||||
config.action_dispatch.rescue_responses = { }
|
config.action_dispatch.rescue_responses = { }
|
||||||
config.action_dispatch.default_charset = nil
|
config.action_dispatch.default_charset = nil
|
||||||
|
config.action_dispatch.rack_cache = false
|
||||||
config.action_dispatch.rack_cache = {
|
|
||||||
:metastore => "rails:/",
|
|
||||||
:entitystore => "rails:/",
|
|
||||||
:verbose => false
|
|
||||||
}
|
|
||||||
|
|
||||||
config.action_dispatch.default_headers = {
|
config.action_dispatch.default_headers = {
|
||||||
'X-Frame-Options' => 'SAMEORIGIN',
|
'X-Frame-Options' => 'SAMEORIGIN',
|
||||||
|
|
|
@ -297,6 +297,15 @@ module Rails
|
||||||
error.message << ' Be sure to add rack-cache to your Gemfile'
|
error.message << ' Be sure to add rack-cache to your Gemfile'
|
||||||
raise
|
raise
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if rack_cache == true
|
||||||
|
rack_cache = {
|
||||||
|
:metastore => "rails:/",
|
||||||
|
:entitystore => "rails:/",
|
||||||
|
:verbose => false
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
require "action_dispatch/http/rack_cache"
|
require "action_dispatch/http/rack_cache"
|
||||||
middleware.use ::Rack::Cache, rack_cache
|
middleware.use ::Rack::Cache, rack_cache
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,6 +14,11 @@
|
||||||
config.consider_all_requests_local = false
|
config.consider_all_requests_local = false
|
||||||
config.action_controller.perform_caching = true
|
config.action_controller.perform_caching = true
|
||||||
|
|
||||||
|
# Enable Rack::Cache to put a simple HTTP cache in front of your application
|
||||||
|
# Add `rack-cache` to your Gemfile before enabling this.
|
||||||
|
# For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
|
||||||
|
# config.action_dispatch.rack_cache = true
|
||||||
|
|
||||||
# Disable Rails's static asset server (Apache or nginx will already do this).
|
# Disable Rails's static asset server (Apache or nginx will already do this).
|
||||||
config.serve_static_assets = false
|
config.serve_static_assets = false
|
||||||
|
|
||||||
|
|
|
@ -56,11 +56,20 @@ module ApplicationTests
|
||||||
assert !middleware.include?("Rack::Sendfile"), "Rack::Sendfile is not included in the default stack unless you set config.action_dispatch.x_sendfile_header"
|
assert !middleware.include?("Rack::Sendfile"), "Rack::Sendfile is not included in the default stack unless you set config.action_dispatch.x_sendfile_header"
|
||||||
end
|
end
|
||||||
|
|
||||||
test "Rack::Cache is present when action_controller.perform_caching is set" do
|
test "Rack::Cache is not included by default" do
|
||||||
add_to_config "config.action_controller.perform_caching = true"
|
add_to_config "config.action_controller.perform_caching = true"
|
||||||
|
|
||||||
boot!
|
boot!
|
||||||
|
|
||||||
|
assert !middleware.include?("Rack::Cache"), "Rack::Cache is not included in the default stack unless you set config.action_dispatch.rack_cache"
|
||||||
|
end
|
||||||
|
|
||||||
|
test "Rack::Cache is present when action_controller.perform_caching is set and action_dispatch.rack_cache is set" do
|
||||||
|
add_to_config "config.action_controller.perform_caching = true"
|
||||||
|
add_to_config "config.action_dispatch.rack_cache = true"
|
||||||
|
|
||||||
|
boot!
|
||||||
|
|
||||||
assert_equal "Rack::Cache", middleware.first
|
assert_equal "Rack::Cache", middleware.first
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue