Skip to content

A platform for community discussion. Free, open, simple.

PERF: omit HTML view from sessions by logged on users. (#26170)

Same05628c07935
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 7be04964336..2f09d35e9f7 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -436,7 +436,7 @@ module ApplicationHelper
end
def include_crawler_content?
- crawler_layout? || !mobile_view? || !modern_mobile_device?
+ (crawler_layout? || !mobile_view? || !modern_mobile_device?) && !current_user
end
def modern_mobile_device?
diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb
index 7704983e220..013e7143b41 100644
--- a/spec/helpers/application_helper_spec.rb
+++ b/spec/helpers/application_helper_spec.rb
@@ -10,6 +10,14 @@ RSpec.describe ApplicationHelper do
HTML
end
+ it "does not send crawler content to logged on users" do
+ controller.stubs(:use_crawler_layout?).returns(false)
+ helper.stubs(:current_user).returns(Fabricate(:user))
+
+ helper.request.user_agent = "Firefox"
+ expect(helper.include_crawler_content?).to eq(false)
+ end
+
it "sends crawler content to old mobiles" do
controller.stubs(:use_crawler_layout?).returns(false)