You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By opening the network inspector and finding the request to /__manifest?..., you can note that the Cache-Control header is set to public, max-age=31536000, immutable - this is set in the server runtime here:
I'm not sure the original intention of Cache-Control header here, but doing so causes CDNs like CloudFront to cache the response which introduces two issues:
After deploying a new application version, client-side navigation can break as stale versions of the manifest can be served. If the new/old pages have incompatible dependencies (e.g. upgrading React versions), this can break navigation in unexpected ways. This can also break the route discovery itself, leading to client-side navigations that return 404, but resolve on refresh.
The recent PR Detect lazy route discovery manifest version mismatches and trigger reloads #13061 introduced detection for manifest version mismatches, however these mismatches are never detected with the indefinite cache header. Instead, the first request for that manifest/version is cached, and subsequent requests to that same path return the original cached response and are not able to reach the origin and evaluate the check for version skew.
Based on my understanding of the purpose of this manifest, I would expect it not to have a Cache-Control header at all, so that it can be properly evaluated when requested by the client.
Actual Behavior
The Cache-Control header is set to public, max-age=31536000, immutable and CDNs (like CloudFront) will indefinitely cache this response.
The text was updated successfully, but these errors were encountered:
jacobwgillespie
changed the title
Lazy Route Discovery manifests request are cached indefinitely
Lazy Route Discovery manifest responses are cached indefinitely
Mar 9, 2025
Shouldn't CloudFront cache based on all parameters in the query string and since the version parameter will change on each deployment, the cache will be invalidated?
The cache header should only be an issue if the CDN is configured to ignore the query string when caching requests.
I'm using React Router as a...
framework
Reproduction
By opening the network inspector and finding the request to
/__manifest?...
, you can note that theCache-Control
header is set topublic, max-age=31536000, immutable
- this is set in the server runtime here:react-router/packages/react-router/lib/server-runtime/server.ts
Lines 334 to 338 in 796e9ae
System Info
Used Package Manager
pnpm
Expected Behavior
I'm not sure the original intention of
Cache-Control
header here, but doing so causes CDNs like CloudFront to cache the response which introduces two issues:Based on my understanding of the purpose of this manifest, I would expect it not to have a
Cache-Control
header at all, so that it can be properly evaluated when requested by the client.Actual Behavior
The
Cache-Control
header is set topublic, max-age=31536000, immutable
and CDNs (like CloudFront) will indefinitely cache this response.The text was updated successfully, but these errors were encountered: