Skip to content

fix: add MF remote cache invalidation via buildHash and manifest freshness#353

Open
swalker326 wants to merge 2 commits into
mainfrom
fix/mf-cache-invalidation-live-reload
Open

fix: add MF remote cache invalidation via buildHash and manifest freshness#353
swalker326 wants to merge 2 commits into
mainfrom
fix/mf-cache-invalidation-live-reload

Conversation

@swalker326
Copy link
Copy Markdown
Contributor

Summary

  • Add optional buildHash field to ZephyrManifest interface for cache-busting
  • Compute buildHash (SHA-256 of sorted remote_entry_urls) during manifest creation
  • Runtime plugin: always fetch fresh manifest with cache: 'no-cache' + timestamp query param for SSR compatibility
  • Runtime plugin: append ?v=<buildHash> to remote entry URLs so MF runtime treats each new build as a distinct remote
  • Skip buildHash on session storage overrides (local dev)

Related PRs (common branch fix/mf-cache-invalidation-live-reload)

  • zephyr-panel: bypassCache: true on chrome.tabs.reload()
  • zephyr-mono: Worker engine Cache-Control differentiation + ETag
  • zephyr-cloud-io: WebSocket message enrichment with snapshot_id

Problem

Module Federation's runtime caches loaded remotes by URL. When a new version is deployed, the remote entry URL doesn't change (same path, new content), so MF serves the cached old version. The runtime plugin's in-memory manifest cache (window.__ZEPHYR_MANIFEST_CACHE__) also prevents re-fetching updated manifests.

Changes

File Change
libs/zephyr-edge-contract/src/lib/zephyr-manifest.ts Add buildHash?: string to ZephyrManifest
libs/zephyr-agent/src/lib/transformers/ze-create-manifest.ts Compute buildHash from dependency URLs (skipped for standalone apps)
libs/zephyr-xpack-internal/src/xpack-extract/runtime-plugin.ts cache: 'no-cache' + ?_t= on manifest fetch, ?v=buildHash on remote URLs, always re-resolve remotes

Backward Compatibility

  • buildHash is optional — old manifests without it still work (no query param appended)
  • cache: 'no-cache' still allows 304 responses — no performance regression
  • Session storage overrides (local dev) are unaffected

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Feb 11, 2026

🤖 Nx Cloud AI Fix Eligible

An automatically generated fix could have helped fix failing tasks for this run, but Self-healing CI is disabled for this workspace. Visit workspace settings to enable it and get automatic fixes in future runs.

To disable these notifications, a workspace admin can disable them in workspace settings.


View your CI Pipeline Execution ↗ for commit 86e0c52

Command Status Duration Result
nx affected -t build --skipRemoteCache ❌ Failed 45s View ↗
nx affected -t test ✅ Succeeded 1m 41s View ↗
nx affected -t lint ✅ Succeeded 5s View ↗
nx affected --exclude=!libs/** -t build --skipR... ✅ Succeeded 14s View ↗

☁️ Nx Cloud last updated this comment at 2026-02-11 13:26:12 UTC

- Runtime plugin: append ?_t=<timestamp> to manifest fetch URL for
  SSR/Node.js compatibility where fetch cache option is ignored
- Runtime plugin: append ?v=<manifest.timestamp> to remote entry URLs so
  MF runtime treats each new build as a distinct remote (timestamp changes
  every build, unlike remote_entry_url which stays stable for tag/env deploys)
- Runtime plugin: always re-resolve processedRemotes from fresh manifest
- Skip cache-buster on session storage overrides (local dev)
@swalker326 swalker326 force-pushed the fix/mf-cache-invalidation-live-reload branch from 4045a9f to 27e2c32 Compare February 11, 2026 03:04
ryok90
ryok90 previously approved these changes Feb 11, 2026
…rewriting

The worker now appends ?_zv=<snapshot_id> to remote_entry_url values
in zephyr-manifest.json at serve time, so the client-side ?v=timestamp
param is no longer needed.
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.

2 participants