0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-05 22:42:07 +08:00
discourse/plugins/discourse-lti/lib/discourse_lti
Alan Guo Xiang Tan 661ea0c2bd
PERF: Avoid replacing CSP nonces in non-cacheable responses (#42008)
CSP nonce placeholders are replaced after rendering by scanning and
copying the complete response body, even when the response could not
enter the anonymous cache.

Generate the final nonce before rendering non-cacheable requests so
templates can emit it directly. Requests eligible for anonymous caching
continue to use placeholders, preserving a unique nonce each time cached
HTML is served.

On a site with 11K categories for a logged in user, ~400ms was spent
executing `gsub` on the response body.
2026-07-24 09:49:01 +08:00
..
lti_authenticator.rb
lti_omniauth_strategy.rb PERF: Avoid replacing CSP nonces in non-cacheable responses (#42008) 2026-07-24 09:49:01 +08:00