2019-05-02 17:17:27 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-12-30 17:53:30 -06:00
|
|
|
require "middleware/anonymous_cache"
|
2013-04-11 01:24:08 -05:00
|
|
|
|
2013-10-16 00:39:18 -05:00
|
|
|
enabled =
|
|
|
|
if Rails.configuration.respond_to?(:enable_anon_caching)
|
|
|
|
Rails.configuration.enable_anon_caching
|
|
|
|
else
|
2023-07-28 06:53:44 -05:00
|
|
|
Rails.env.production? || Rails.env.test?
|
2013-10-16 00:39:18 -05:00
|
|
|
end
|
2013-05-07 02:32:43 -05:00
|
|
|
|
2013-11-12 22:28:39 -06:00
|
|
|
if !ENV["DISCOURSE_DISABLE_ANON_CACHE"] && enabled
|
2014-01-08 21:08:42 -06:00
|
|
|
# in an ideal world this is position 0, but mobile detection uses ... session and request and params
|
2024-02-16 05:16:54 -06:00
|
|
|
Rails.configuration.middleware.insert_after Middleware::CspScriptNonceInjector,
|
2023-07-28 06:53:44 -05:00
|
|
|
Middleware::AnonymousCache
|
2013-04-11 01:24:08 -05:00
|
|
|
end
|