diff --git a/lib/pact_broker/app.rb b/lib/pact_broker/app.rb index af4c0c932..d44c893b1 100644 --- a/lib/pact_broker/app.rb +++ b/lib/pact_broker/app.rb @@ -21,6 +21,7 @@ require "rack/pact_broker/configurable_make_it_later" require "rack/pact_broker/no_auth" require "rack/pact_broker/reset_thread_data" +require "rack/pact_broker/add_cache_header" require "rack/pact_broker/add_vary_header" require "rack/pact_broker/use_when" require "rack/pact_broker/application_context" @@ -183,6 +184,7 @@ def configure_middleware @app_builder.use Rack::PactBroker::InvalidUriProtection @app_builder.use Rack::PactBroker::ResetThreadData @app_builder.use Rack::PactBroker::AddPactBrokerVersionHeader + @app_builder.use Rack::PactBroker::AddCacheHeader @app_builder.use Rack::PactBroker::AddVaryHeader @app_builder.use Rack::Static, :urls => ["/stylesheets", "/css", "/fonts", "/js", "/javascripts", "/images"], :root => PactBroker.project_root.join("public") @app_builder.use Rack::Static, :urls => ["/favicon.ico"], :root => PactBroker.project_root.join("public/images"), header_rules: [[:all, {"Content-Type" => "image/x-icon"}]] diff --git a/lib/rack/pact_broker/add_cache_header.rb b/lib/rack/pact_broker/add_cache_header.rb new file mode 100644 index 000000000..1f17e9cc9 --- /dev/null +++ b/lib/rack/pact_broker/add_cache_header.rb @@ -0,0 +1,14 @@ +module Rack + module PactBroker + class AddCacheHeader + def initialize app + @app = app + end + + def call(env) + status, headers, body = @app.call(env) + [status, { "Cache-Control" => "no-cache" }.merge(headers || {}), body] + end + end + end +end