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

You need JS to log on to Discourse anyway, HTML only serves for debugging
purpose, no need to send it
This commit is contained in:
Sam 2024-03-14 15:48:29 +11:00 committed by GitHub
parent 1f786f4972
commit e05628c079
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 1 deletions

View File

@ -436,7 +436,7 @@ module ApplicationHelper
end end
def include_crawler_content? def include_crawler_content?
crawler_layout? || !mobile_view? || !modern_mobile_device? (crawler_layout? || !mobile_view? || !modern_mobile_device?) && !current_user
end end
def modern_mobile_device? def modern_mobile_device?

View File

@ -10,6 +10,14 @@ RSpec.describe ApplicationHelper do
HTML HTML
end 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 it "sends crawler content to old mobiles" do
controller.stubs(:use_crawler_layout?).returns(false) controller.stubs(:use_crawler_layout?).returns(false)