diff options
author | José Valim <jose.valim@gmail.com> | 2011-05-03 13:07:39 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-05-03 13:07:39 +0200 |
commit | 1ca81238b5abcbdad667d45a588fdb1f68a0516e (patch) | |
tree | b775f19eeeff93a3efb805eb8f2082116b9cef63 | |
parent | 06ddda0a5f659cab8c2c76cfcb3b27ac5bb47ea6 (diff) | |
download | rails-1ca81238b5abcbdad667d45a588fdb1f68a0516e.tar.gz rails-1ca81238b5abcbdad667d45a588fdb1f68a0516e.tar.bz2 rails-1ca81238b5abcbdad667d45a588fdb1f68a0516e.zip |
Add static_cache_control as configuration option and set a default for test. Should improve performance in acceptance tests.
-rw-r--r-- | railties/lib/rails/application.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/application/configuration.rb | 3 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt | 6 |
3 files changed, 8 insertions, 3 deletions
diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index 0c3c7737ea..4e82761e5d 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -152,7 +152,7 @@ module Rails end if config.serve_static_assets - middleware.use ::ActionDispatch::Static, paths["public"].first + middleware.use ::ActionDispatch::Static, paths["public"].first, config.static_cache_control end middleware.use ::Rack::Lock unless config.allow_concurrency diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb index f818313955..29b9c27a13 100644 --- a/railties/lib/rails/application/configuration.rb +++ b/railties/lib/rails/application/configuration.rb @@ -9,7 +9,7 @@ module Rails :dependency_loading, :encoding, :filter_parameters, :force_ssl, :helpers_paths, :logger, :preload_frameworks, :reload_plugins, :secret_token, :serve_static_assets, - :session_options, :time_zone, :whiny_nils + :static_cache_control, :session_options, :time_zone, :whiny_nils attr_writer :log_level @@ -22,6 +22,7 @@ module Rails @helpers_paths = [] @dependency_loading = true @serve_static_assets = true + @static_cache_control = nil @force_ssl = false @session_store = :cookie_store @session_options = {} diff --git a/railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt index d8d1e55157..8d11377211 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +++ b/railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt @@ -7,7 +7,11 @@ # and recreated between test runs. Don't rely on the data there! config.cache_classes = true - # Log error messages when you accidentally call methods on nil. + # Configure static asset server for tests with Cache-Control for performance + config.serve_static_assets = true + config.static_cache_control = "public, max-age=3600" + + # Log error messages when you accidentally call methods on nil config.whiny_nils = true # Show full error reports and disable caching |