FIX: remove slow platform detection from server side

Historically due to https://meta.discourse.org/t/why-is-discourse-so-slow-on-android/8823
we decreased page sizes of both home page and topic page on android by half.

This was done on the server side and as a side effect and caused page sizes on android
to mismatch between Android and non Android.

Unfortunately about a year ago googlebot started pretending it is Android,
this cause Google to start indexing pages as what android would see. So
it saw double the amount of pages in the index as what exists on desktop.
This in turn caused double the amount of indexing work and a large amount
of broken links on long topics.

This fix removes all special behavior which is no longer needed due to
other performance work in Discourse including raw handlebars on home page
and virtual dom on topic pages.

I tested we do not need this on Blu Advance 5.0 it has 1.3 GHZ mediatec mt6580
This phone retails for around $50 USD.

If we decide long term that we want any hacks like this we will shift them
to the client side. It can just hold data in memory without rendering.
This commit is contained in:
Sam
2018-12-13 13:56:49 +11:00
parent 92df7b212c
commit 94b8ba4f8f
7 changed files with 1 additions and 19 deletions

View File

@ -101,10 +101,6 @@ class ApplicationController < ActionController::Base
end end
end end
def slow_platform?
request.user_agent =~ /Android/
end
def set_layout def set_layout
use_crawler_layout? ? 'crawler' : 'application' use_crawler_layout? ? 'crawler' : 'application'
end end

View File

@ -383,7 +383,6 @@ class ListController < ApplicationController
# hacky columns get special handling # hacky columns get special handling
options[:topic_ids] = param_to_integer_list(:topic_ids) options[:topic_ids] = param_to_integer_list(:topic_ids)
options[:no_subcategories] = options[:no_subcategories] == 'true' options[:no_subcategories] = options[:no_subcategories] == 'true'
options[:slow_platform] = slow_platform?
options options
end end

View File

@ -351,7 +351,6 @@ class TagsController < ::ApplicationController
q: params[:q] q: params[:q]
} }
options[:no_subcategories] = true if params[:no_subcategories] == 'true' options[:no_subcategories] = true if params[:no_subcategories] == 'true'
options[:slow_platform] = true if slow_platform?
if params[:tag_id] == 'none' if params[:tag_id] == 'none'
options[:no_tags] = true options[:no_tags] = true

View File

@ -64,7 +64,6 @@ class TopicsController < ApplicationController
opts = params.slice(:username_filters, :filter, :page, :post_number, :show_deleted) opts = params.slice(:username_filters, :filter, :page, :post_number, :show_deleted)
username_filters = opts[:username_filters] username_filters = opts[:username_filters]
opts[:slow_platform] = true if slow_platform?
opts[:print] = true if params[:print].present? opts[:print] = true if params[:print].present?
opts[:username_filters] = username_filters.split(',') if username_filters.is_a?(String) opts[:username_filters] = username_filters.split(',') if username_filters.is_a?(String)

View File

@ -67,7 +67,6 @@ class TopicQuery
tags tags
match_all_tags match_all_tags
no_subcategories no_subcategories
slow_platform
no_tags) no_tags)
end end
@ -495,7 +494,7 @@ class TopicQuery
protected protected
def per_page_setting def per_page_setting
@options[:slow_platform] ? 15 : 30 30
end end
def private_messages_for(user, type) def private_messages_for(user, type)

View File

@ -9,10 +9,6 @@ class TopicView
attr_reader :topic, :posts, :guardian, :filtered_posts, :chunk_size, :print, :message_bus_last_id attr_reader :topic, :posts, :guardian, :filtered_posts, :chunk_size, :print, :message_bus_last_id
attr_accessor :draft, :draft_key, :draft_sequence, :user_custom_fields, :post_custom_fields, :post_number attr_accessor :draft, :draft_key, :draft_sequence, :user_custom_fields, :post_custom_fields, :post_number
def self.slow_chunk_size
10
end
def self.print_chunk_size def self.print_chunk_size
1000 1000
end end
@ -57,7 +53,6 @@ class TopicView
@chunk_size = @chunk_size =
case case
when options[:slow_platform] then TopicView.slow_chunk_size
when @print then TopicView.print_chunk_size when @print then TopicView.print_chunk_size
else TopicView.chunk_size else TopicView.chunk_size
end end

View File

@ -36,11 +36,6 @@ describe TopicView do
expect(TopicView.new(topic.id, evil_trout).chunk_size).to eq(TopicView.chunk_size) expect(TopicView.new(topic.id, evil_trout).chunk_size).to eq(TopicView.chunk_size)
end end
it "returns `slow_chunk_size` when slow_platform is true" do
tv = TopicView.new(topic.id, evil_trout, slow_platform: true)
expect(tv.chunk_size).to eq(TopicView.slow_chunk_size)
end
it "returns `print_chunk_size` when print param is true" do it "returns `print_chunk_size` when print param is true" do
tv = TopicView.new(topic.id, evil_trout, print: true) tv = TopicView.new(topic.id, evil_trout, print: true)
expect(tv.chunk_size).to eq(TopicView.print_chunk_size) expect(tv.chunk_size).to eq(TopicView.print_chunk_size)