Repository navigation
fix(core): cache Content Platform template list across page generations (3.x) - #3534
Merged
Merged
Conversation
…ns (3.x) Backport of #3526 (b03ed33) to 3.x. On Content Platform stores, each cold PLP/PDP generation paginates listEntries and fetches every entry to pick a template, costing ceil(N / 20) + N CP calls per page. getMultipleContent now memoizes "list entries + fetch each entry" per (accountName, storeId, contentType, locale), with in-flight deduplication and a 5-minute TTL. Previews bypass the cache, and failures are not cached. Differences from dev: - 3.x has no OPTIONAL_CONTENT_TYPES; that hunk was dropped. - 3.x passes no locale to the CP client, so the locale part of the key is always undefined. - The tests are ported from Vitest to Jest, without the per-locale case. Co-authored-by: Cursor <[email protected]>
lemagnetic
requested review from
eduardoformiga and
hellofanny
and removed request for
a team
October 21, 2026 17:08
Contributor
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
eduardoformiga
approved these changes
Oct 22, 2026
This was referenced Oct 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's the purpose of this pull request?
Backport of #3526 to
3.x.3.xhas had the same Content Platform (CP) template lookup sincev3.100.2(#3384). Theplp/entries/slug/:sluglookup 404s with the defaultplpschema. On that 404,getMultipleContentpaginateslistEntriesand then fetches every entry to readsettings.template.value. So each cold PLP/PDP generation costsceil(N / 20) + NCP calls, and nothing is reused between page generations. On a store with ~330 PLP entries, that is about 350 CP calls per collection, fired in bursts right after each build.How it works?
The logic is the same as in #3526.
ContentService.getMultipleContent(CP branch) memoizes "list entries + fetch each entry" per process:(accountName, storeId, contentType, locale). The page slug stays out of the key, so every collection shares one list.The scroll loop and
fillEntriesWithDatamoved unchanged into a privatelistAndFillEntries. Template selection and the hCMS path are untouched, and nothing public changes.Differences from
dev3.xhas noOPTIONAL_CONTENT_TYPES, so that hunk of the cherry-pick was dropped.3.xdoesn't pass a locale to the CP client, so the locale part of the key is alwaysundefined. In practice the key is(accountName, storeId, contentType).3.xruns Jest, sotest/server/content/service.test.tsis a Jest port of the Vitest suite, minus the per-locale case.How to test it?
cd packages/core && pnpm jest test/server/content/service.test.ts. It runs 9 tests: concurrent PLPs with different slugs share one list, reuse within the TTL, the direct slug match still wins, scroll pagination, separate keys per content type, preview bypass, failures not cached, a late failure not evicting a newer fetch, and TTL expiry.3.xservice.ts, 7 of the 9 tests fail.packages/coreJest suite passes locally (119 tests). The one exception istest/server/index.test.ts, which can't load locally without@faststore/apibuilt and@generated/persisted-documents.json. This PR doesn't touch it.Starters Deploy Preview
N/A (server-side content fetching only)
References
Checklist
bug/performanceSummary by CodeRabbit
Performance
Reliability