diff --git a/lib/propshaft/railtie.rb b/lib/propshaft/railtie.rb index 4fe2954..6d6daf2 100644 --- a/lib/propshaft/railtie.rb +++ b/lib/propshaft/railtie.rb @@ -15,6 +15,11 @@ class Railtie < ::Rails::Railtie [ "text/css", Propshaft::Compilers::SourceMappingUrls ], [ "text/javascript", Propshaft::Compilers::SourceMappingUrls ] ] + if Rails.env.development? + config.assets.cache_control_header = "no-store" + else + config.assets.cache_control_header = "public, max-age=31536000, immutable" + end config.assets.sweep_cache = Rails.env.development? config.assets.server = Rails.env.development? || Rails.env.test? diff --git a/lib/propshaft/server.rb b/lib/propshaft/server.rb index 8cad181..fc58d91 100644 --- a/lib/propshaft/server.rb +++ b/lib/propshaft/server.rb @@ -18,7 +18,7 @@ def call(env) "content-type" => asset.content_type.to_s, "accept-encoding" => "vary", "etag" => asset.digest, - "cache-control" => "public, max-age=31536000, immutable" + "cache-control" => Rails.application.config.assets.cache_control_header }, [ compiled_content ] ]