Skip to content

Improve Site Defaults performance with many sites#624

Merged
duncanmcclean merged 2 commits into
7.xfrom
cache-site-defaults
Jul 2, 2026
Merged

Improve Site Defaults performance with many sites#624
duncanmcclean merged 2 commits into
7.xfrom
cache-site-defaults

Conversation

@duncanmcclean

Copy link
Copy Markdown
Member

This pull request fixes performance issues with Site Defaults that get noticeably worse as the number of configured sites grows — the Site Defaults page in the Control Panel could take 30 seconds or more to load, and there was a slowdown on the front-end during metadata retrieval.

This was happening because SiteDefaults::origins() rebuilt the addon settings from disk on every call (a YAML parse plus running Antlers over every stored value), and it's called once per site while building the page, so the work scaled roughly with the square of the site count. LocalizedSiteDefaults::augmented() had a similar issue, running two full blueprint augmentation passes on every call with no memoization.

This PR fixes it by memoizing both with Blink::once — matching how SiteDefaults::get() and the section defaults equivalent are already cached — and invalidating the caches when defaults are saved.

duncanmcclean and others added 2 commits July 2, 2026 10:34
`SiteDefaults::origins()` rebuilt the addon settings from disk (YAML
parse + Antlers over every stored value) on every call, and it's called
once per site while building the page. On installs with many sites this
made the Site Defaults page take 30s+ to load.

Memoize the getter with Blink::once, matching how `get()` is already
cached, and invalidate it alongside the existing cache when origins are
saved.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
`LocalizedSiteDefaults::augmented()` ran two full blueprint augmentation
passes on every call with no memoization, which is repeated per-item in
the sitemap, reporting and GraphQL paths.

Wrap it in Blink::once per locale, matching the section defaults
equivalent, and invalidate it when defaults are saved.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@duncanmcclean duncanmcclean merged commit 666dea5 into 7.x Jul 2, 2026
17 checks passed
@duncanmcclean duncanmcclean deleted the cache-site-defaults branch July 2, 2026 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant