2019-05-03 06:17:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-12-31 07:53:30 +08:00
|
|
|
require "middleware/anonymous_cache"
|
2013-04-11 14:24:08 +08:00
|
|
|
|
2013-10-16 13:39:18 +08:00
|
|
|
enabled =
|
|
|
|
if Rails.configuration.respond_to?(:enable_anon_caching)
|
|
|
|
Rails.configuration.enable_anon_caching
|
|
|
|
else
|
|
|
|
Rails.env.production?
|
|
|
|
end
|
2013-05-07 15:32:43 +08:00
|
|
|
|
2013-11-13 12:28:39 +08:00
|
|
|
if !ENV['DISCOURSE_DISABLE_ANON_CACHE'] && enabled
|
2014-01-09 11:08:42 +08:00
|
|
|
# in an ideal world this is position 0, but mobile detection uses ... session and request and params
|
2017-08-31 12:06:56 +08:00
|
|
|
Rails.configuration.middleware.insert_after ActionDispatch::Flash, Middleware::AnonymousCache
|
2013-04-11 14:24:08 +08:00
|
|
|
end
|