mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Remove legacy /brotli_asset workaround (#24243)
When Discourse first introduced brotli support, reverse-proxy/CDN support for passing through the accept-encoding header to our NGINX server was very poor. Therefore, a separate `/brotli_assets/...` path was introduced to serve the brotli assets. This worked well, but introduces additional complexity and inconsistencies. Nowadays, Brotli encoding is well supported, so we don't need the separate paths any more. Requests can be routed to the asset `.js` URLs, and NGINX will serve the brotli/gzip version of the asset automatically.
This commit is contained in:
@@ -3,14 +3,11 @@
|
||||
class StaticController < ApplicationController
|
||||
skip_before_action :check_xhr, :redirect_to_login_if_required
|
||||
skip_before_action :verify_authenticity_token,
|
||||
only: %i[brotli_asset cdn_asset enter favicon service_worker_asset]
|
||||
skip_before_action :preload_json,
|
||||
only: %i[brotli_asset cdn_asset enter favicon service_worker_asset]
|
||||
skip_before_action :handle_theme,
|
||||
only: %i[brotli_asset cdn_asset enter favicon service_worker_asset]
|
||||
only: %i[cdn_asset enter favicon service_worker_asset]
|
||||
skip_before_action :preload_json, only: %i[cdn_asset enter favicon service_worker_asset]
|
||||
skip_before_action :handle_theme, only: %i[cdn_asset enter favicon service_worker_asset]
|
||||
|
||||
before_action :apply_cdn_headers,
|
||||
only: %i[brotli_asset cdn_asset enter favicon service_worker_asset]
|
||||
before_action :apply_cdn_headers, only: %i[cdn_asset enter favicon service_worker_asset]
|
||||
|
||||
PAGES_WITH_EMAIL_PARAM = %w[login password_reset signup]
|
||||
MODAL_PAGES = %w[password_reset signup]
|
||||
@@ -190,16 +187,6 @@ class StaticController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
def brotli_asset
|
||||
is_asset_path
|
||||
|
||||
if params[:path].end_with?(".map")
|
||||
serve_asset
|
||||
else
|
||||
serve_asset(".br") { response.headers["Content-Encoding"] = "br" }
|
||||
end
|
||||
end
|
||||
|
||||
def cdn_asset
|
||||
is_asset_path
|
||||
|
||||
|
||||
@@ -125,9 +125,6 @@ module ApplicationHelper
|
||||
path = path.gsub(/\.([^.]+)\z/, '.gz.\1')
|
||||
end
|
||||
end
|
||||
elsif GlobalSetting.cdn_url&.start_with?("https") && is_brotli_req? &&
|
||||
Rails.env != "development"
|
||||
path = path.gsub("#{GlobalSetting.cdn_url}/assets/", "#{GlobalSetting.cdn_url}/brotli_asset/")
|
||||
end
|
||||
|
||||
path
|
||||
|
||||
Reference in New Issue
Block a user