Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add static_cache_control as configuration option and set a default fo…

…r test. Should improve performance in acceptance tests.
  • Loading branch information...
commit 1ca81238b5abcbdad667d45a588fdb1f68a0516e 1 parent 06ddda0
@josevalim josevalim authored
View
2  railties/lib/rails/application.rb
@@ -152,7 +152,7 @@ def default_middleware_stack
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
View
3  railties/lib/rails/application/configuration.rb
@@ -9,7 +9,7 @@ class Configuration < ::Rails::Engine::Configuration
: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 @@ def initialize(*)
@helpers_paths = []
@dependency_loading = true
@serve_static_assets = true
+ @static_cache_control = nil
@force_ssl = false
@session_store = :cookie_store
@session_options = {}
View
6 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
Please sign in to comment.
Something went wrong with that request. Please try again.