diff --git a/railties/lib/rails/application/default_middleware_stack.rb b/railties/lib/rails/application/default_middleware_stack.rb index 570ff02c833027c5039153d2e134dcf3820f836e..a00afe008c0c55847f045d07089438d49b7c31a1 100644 --- a/railties/lib/rails/application/default_middleware_stack.rb +++ b/railties/lib/rails/application/default_middleware_stack.rb @@ -11,11 +11,6 @@ def initialize(app, config, paths) def build_stack ActionDispatch::MiddlewareStack.new.tap do |middleware| - if rack_cache = load_rack_cache - require "action_dispatch/http/rack_cache" - middleware.use ::Rack::Cache, rack_cache - end - if config.force_ssl middleware.use ::ActionDispatch::SSL, config.ssl_options end @@ -26,6 +21,11 @@ def build_stack middleware.use ::ActionDispatch::Static, paths["public"].first, config.static_cache_control end + if rack_cache = load_rack_cache + require "action_dispatch/http/rack_cache" + middleware.use ::Rack::Cache, rack_cache + end + middleware.use ::Rack::Lock unless allow_concurrency? middleware.use ::Rack::Runtime middleware.use ::Rack::MethodOverride diff --git a/railties/test/application/middleware_test.rb b/railties/test/application/middleware_test.rb index 20d1d76d7895a0791832f4cbd5d884eaa9e4de3a..1557b90d2729958ab89923d3295fa8691a93301d 100644 --- a/railties/test/application/middleware_test.rb +++ b/railties/test/application/middleware_test.rb @@ -61,7 +61,7 @@ def app boot! - assert_equal "Rack::Cache", middleware.first + assert middleware.include?("Rack::Cache") end test "ActiveRecord::Migration::CheckPending is present when active_record.migration_error is set to :page_load" do