diff --git a/config/environments/profile.rb b/config/environments/profile.rb index 98e74548da0..e261db93b6b 100644 --- a/config/environments/profile.rb +++ b/config/environments/profile.rb @@ -37,7 +37,7 @@ Discourse::Application.configure do config.handlebars.precompile = true # this setting enable rack_cache so it caches various requests in redis - config.enable_rack_cache = false + config.enable_rack_cache = true # allows users to use mini profiler config.enable_mini_profiler = false diff --git a/config/initializers/99-rack-cache.rb b/config/initializers/99-rack-cache.rb index 44595c26d98..292d310d0fb 100644 --- a/config/initializers/99-rack-cache.rb +++ b/config/initializers/99-rack-cache.rb @@ -4,7 +4,21 @@ if Rails.configuration.respond_to?(:enable_rack_cache) && Rails.configuration.en url = DiscourseRedis.url - Rails.configuration.middleware.insert 0, Rack::Cache, + class Rack::Cache::Discourse < Rack::Cache::Context + def initialize(app, options={}) + @app = app + super + end + def call(env) + if CurrentUser.has_auth_cookie?(env) + @app.call(env) + else + super + end + end + end + + Rails.configuration.middleware.insert 0, Rack::Cache::Discourse, metastore: "#{url}/metastore", entitystore: "#{url}/entitystore", verbose: !Rails.env.production?