A platform for community discussion. Free, open, simple.
PERF: avoid following links in topic RSS feeds (#16145)
Sam43da88db6c63
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rbindex b4b1013b372..22f47bd8bdb 100644--- a/app/controllers/application_controller.rb+++ b/app/controllers/application_controller.rb@@ -897,7 +897,7 @@ class ApplicationController < ActionController::Baseenddef add_noindex_header- if request.get?+ if request.get? && !response.headers['X-Robots-Tag']if SiteSetting.allow_index_in_robots_txtresponse.headers['X-Robots-Tag'] = 'noindex'elsediff --git a/app/controllers/topics_controller.rb b/app/controllers/topics_controller.rbindex 5d1513fbcfd..da12f1c86e1 100644--- a/app/controllers/topics_controller.rb+++ b/app/controllers/topics_controller.rb@@ -922,6 +922,8 @@ class TopicsController < ApplicationControllerenddiscourse_expires_in 1.minute++ response.headers['X-Robots-Tag'] = 'noindex, nofollow'render 'topics/show', formats: [:rss]enddiff --git a/spec/requests/topics_controller_spec.rb b/spec/requests/topics_controller_spec.rbindex 6b7ca165742..ed2cb355663 100644--- a/spec/requests/topics_controller_spec.rb+++ b/spec/requests/topics_controller_spec.rb@@ -2850,6 +2850,11 @@ RSpec.describe TopicsController doget "/t/foo/#{topic.id}.rss"expect(response.status).to eq(200)expect(response.media_type).to eq('application/rss+xml')++ # our RSS feed is full of post 1/2/3/4/5 links, we do not want it included+ # in the index, and do not want links followed+ # this allows us to remove it while allowing via robots.txt+ expect(response.headers['X-Robots-Tag']).to eq('noindex, nofollow')endit 'renders rss of the topic correctly with subfolder' do