correct rack::cache so it always punches through users with auth cookies

This commit is contained in:
Sam 2013-04-12 21:59:52 +10:00
parent 1725bf77a7
commit 8014d7fd25
2 changed files with 16 additions and 2 deletions

View File

@ -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

View File

@ -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?