Repository navigation
fix(useSection): key lazy-section cache on block content, not release revision - #1243
Draft
pedrofrxncx wants to merge 1 commit into
Draft
pedrofrxncx wants to merge 1 commit into
pedrofrxncx wants to merge 1 commit into
Conversation
… revision __cb hashed the global release revision, so every CMS publish (a decofile hot-reload, no deploy) changed the /deco/render URL of every lazy section on every page and threw away their warm CDN entries. Hash the named blocks on the section's resolve chain instead (e.g. the page it lives in), memoized per block object. A publish now only busts lazy sections of the blocks it changed. Falls back to the revision when the chain has no named block; deploymentId, vary and href stay in the key.
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Contributor
Tagging OptionsShould a new tag be published when this PR is merged?
|
This branch has not been deployed
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.
Why
useSectionbuilds the/deco/renderURL with__cb = hash(release revision, vary, href, deploymentId). The release revision changes on every CMS publish, even a decofile-only publish that doesn't redeploy. So every publish changes the URL of every lazy section on every page, and the CDN entries already warm undermax-age=300, stale-while-revalidate=3600are thrown away.Measured on miess-01 (2026-10-13, 10:00–21:00Z, Cloudflare logs for
www.miess.com.br):/deco/renderhit rate was about 33–41% in quiet windows and fell to 13–20% during publish bursts.__cbhad been requested in the previous 65 minutes under a different__cb:What
The global revision is replaced with a content version: a hash of the named blocks (
resolvableentries) on the section's resolve chain, for examplepages-category-…, plus any named section block the section is resolved through.deploymentId,varyandhrefstay in the key, so a deploy still busts everything.Same-shell semantics are unchanged:
sections, because the page block's content changes.Trade-off: a change to a named block that is referenced from a section's props but isn't on its resolve chain (e.g. a shared loader config) no longer busts that section's render URL. It refreshes through the normal
max-age=300+ SWR revalidation, the same freshness HTML pages already have.Tests
hooks/useSection.test.tsx: a new block-content__cbsuite, 4 steps:main(2 of 4) and pass with this change.Not validated yet (why this is a draft)
__cbwhile the edited page's sections get a new one.Summary by cubic
Keys the lazy-section cache on the content of the blocks on the section's resolve chain instead of the global release revision, so a CMS publish that doesn't change a page no longer invalidates that page's warm CDN entries.
__cbhash now covers the named blocks the section resolves through (e.g. the page), with hashes memoized per block object.deploymentId,vary, andhrefremain in the key.Written for commit 8031a1f. Summary will update on new commits.