mirror of
https://github.com/discourse/discourse.git
synced 2025-05-28 13:51:18 +08:00
* Revert "Revert "FEATURE: Preload resources via link header (#18475)" (#18511)" This reverts commit 95a57f7e0c7e78ecac14760ae4751e0ae2e8ea0d. * put behind feature flag * env -> global setting * declare global setting * forgot one spot
This commit is contained in:

committed by
GitHub

parent
47fa4dbef3
commit
6888eb5c2d
@ -49,7 +49,8 @@ class ApplicationController < ActionController::Base
|
||||
after_action :conditionally_allow_site_embedding
|
||||
after_action :ensure_vary_header
|
||||
after_action :add_noindex_header, if: -> { is_feed_request? || !SiteSetting.allow_index_in_robots_txt }
|
||||
after_action :add_noindex_header_to_non_canonical, if: -> { request.get? && !(request.format && request.format.json?) && !request.xhr? }
|
||||
after_action :add_noindex_header_to_non_canonical, if: :spa_boot_request?
|
||||
around_action :link_preload, if: -> { spa_boot_request? && GlobalSetting.preload_link_header }
|
||||
|
||||
HONEYPOT_KEY ||= 'HONEYPOT_KEY'
|
||||
CHALLENGE_KEY ||= 'CHALLENGE_KEY'
|
||||
@ -1008,4 +1009,14 @@ class ApplicationController < ActionController::Base
|
||||
|
||||
result
|
||||
end
|
||||
|
||||
def link_preload
|
||||
@links_to_preload = []
|
||||
yield
|
||||
response.headers['Link'] = @links_to_preload.join(', ') if !@links_to_preload.empty?
|
||||
end
|
||||
|
||||
def spa_boot_request?
|
||||
request.get? && !(request.format && request.format.json?) && !request.xhr?
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user