PERF: Preload client settings json while booting app. (#13283)

Generating the client settings json involves santizing all string based
site settings. This is expensive as per our profile in production (~120ms) and one request after each deploy has
to pay this penalty.
This commit is contained in:
Alan Guo Xiang Tan 2021-06-08 11:15:55 +08:00 committed by GitHub
parent 19a92fbadc
commit 2717615f11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View File

@ -942,6 +942,14 @@ module Discourse
JsLocaleHelper.load_translations(SiteSetting.default_locale)
Site.json_for(Guardian.new)
SvgSprite.preload
begin
SiteSetting.client_settings_json
rescue => e
# Rescue from Redis related errors so that we can still boot the
# application even if Redis is down.
warn_exception(e, message: "Error while preloading client settings json")
end
end
[