Skip to content

fix: rebuild pages whose navigation changed under incremental builds - #308

Merged
MohamedH1998 merged 2 commits into
mainfrom
fix/incremental-nav-cache-key
Oct 28, 2026
Merged

MohamedH1998 merged 2 commits into
mainfrom
fix/incremental-nav-cache-key

Conversation

@MohamedH1998

Copy link
Copy Markdown
Collaborator

Summary

With Astro's experimental.incrementalBuild, a docs page was keyed on its own file only. Renaming, adding or removing a sibling left every other page's sidebar, breadcrumbs and prev/next links stale, because Astro only tracks the content entries a page renders, not the ones it reads titles from.

  • Each path's cacheKey now covers the entry's digest and a digest of the collection's navigation tree. A sibling's rename rebuilds the pages that show it; a body edit still rebuilds only that page.
  • An entry whose loader gives no digest gets no key and is rendered every build, instead of sharing one key with every other such entry.
  • The first build after upgrading renders every page once, since every key changes.

Nothing changes on sites without the flag.

Before → after

No config, API, type or user-owned file changes. A route that draws from other inputs appends its own digest, as the helper's JSDoc now shows:

export const getStaticPaths: GetStaticPaths = async (options) =>
  (await getDocsStaticPaths(options)).map((path) => ({
    ...path,
    cacheKey: path.cacheKey && `${path.cacheKey}:${myDigest}`,
  }));

Checks

  • pnpm --filter @cloudflare/nimbus-docs typecheck: pass
  • pnpm lint: pass
  • New test/incremental-build.test.ts (four builds of one site: cold, a body edit, a sibling's rename, no change): pass. On main it fails at the rename step, where every page is restored from cache with the old title.
  • pnpm --filter @cloudflare/nimbus-docs test: 3,215 pass, 1 fail. The failure is content-sources-snapshots.test.ts "a repository that needs credentials … never prompts", which times out identically on main in this environment.

Not in this PR

  • Pages whose breadcrumb labels come from entries outside the sidebar tree, and "last updated" dates read from git, can still go stale under the flag.
  • A .md partial shown through Render has no render hash in Astro, so its edits don't rebuild the pages that include it; MDX partials do.
  • API pages key on prepared spec artifacts and are unchanged.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview URL: https://fix-incremental-nav-cache-key.nimbus-docs.com (commit c29ffa5)

This URL reflects your latest Preview deployment

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://55cc0c98.nimbus-docs.com c29ffa5 2026-10-26T14:01:10.856Z Visit the dashboard ↗

@MohamedH1998
MohamedH1998 marked this pull request as ready for review October 28, 2026 10:57
@MohamedH1998
MohamedH1998 merged commit 7549dec into main Oct 28, 2026
42 checks passed
@MohamedH1998
MohamedH1998 deleted the fix/incremental-nav-cache-key branch October 28, 2026 11:03

This branch was successfully deployed

1 active deployment
cloudflare — c29ffa56 Deployed Oct 28, 2026 by MohamedH1998 via Delete closed PR Preview #55
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