Replace middleware with executor callback.

Per request digest caches were added before we had hooks into
different units of work that Rails performs.

As such the most reliable way to prevent stale cache digests
was with a middleware. The middleware prevented staleness in
Action Controller requests.

However, the executor is superior because it should also prevent
staleness when running just Active Job jobs or broadcasting
through Action Cable's server.
This commit is contained in:
Kasper Timm Hansen 2016-05-16 21:34:16 +02:00
parent 8fffee4b1c
commit 23b6a9c0fc
2 changed files with 1 additions and 8 deletions

View File

@ -6,13 +6,6 @@ module ActionView
class Digestor
@@digest_mutex = Mutex.new
class PerRequestDigestCacheExpiry < Struct.new(:app) # :nodoc:
def call(env)
ActionView::LookupContext::DetailsKey.clear
app.call(env)
end
end
class << self
# Supported options:
#

View File

@ -40,7 +40,7 @@ module ActionView
initializer "action_view.per_request_digest_cache" do |app|
ActiveSupport.on_load(:action_view) do
if app.config.consider_all_requests_local
app.middleware.use ActionView::Digestor::PerRequestDigestCacheExpiry
app.executor.to_run { ActionView::LookupContext::DetailsKey.clear }
end
end
end