diff --git a/lib/middleware/anonymous_cache.rb b/lib/middleware/anonymous_cache.rb index 2fe75b05bee..92a9143a073 100644 --- a/lib/middleware/anonymous_cache.rb +++ b/lib/middleware/anonymous_cache.rb @@ -140,16 +140,16 @@ module Middleware def call(env) helper = Helper.new(env) - Scheduler::Defer.later "Track view" do - self.class.log_request_on_site(env,helper) - end - if helper.cacheable? helper.cached or helper.cache(@app.call(env)) else @app.call(env) end + ensure + Scheduler::Defer.later "Track view" do + self.class.log_request_on_site(env,helper) + end end end