Files
next.js/test/e2e/middleware-rewrites/app/pages/dynamic-no-cache/[id].js
Zack TannerandGitHub 9b6f713b26 pages router: ensure x-middleware-cache is respected (#67734)
`x-middleware-cache: "no-store"` in Pages router is a way to signal to
the client that it should not store the response in the cache. However
in certain circumstances, namely when `unstable_skipClientCache` is
true, the data request would be awaited and then stored in the
`inflightCache` regardless of the header.

The original implementation of this in the router has logic to delete
the response from the inflight cache after the request has fulfilled
because `inflightCache` stores the unresolved promise. But in this
optimistic prefetch case, when we're only storing it in the cache once
the request is fulfilled, we can prevent a race condition where the
ignored prefetch is erroneously re-added to the cache by ensuring it's
never added to the cache to begin with if the response says not to.

Fixes #66881
Closes NEXT-3550
2024-07-13 10:48:38 -07:00

23 lines
384 B
JavaScript

export default function Dynamic({ id }) {
return (
<main id="dynamic-page">
<h1>Page {id}</h1>
</main>
)
}
export const getStaticProps = async ({ params }) => {
return {
props: {
id: params.id,
},
}
}
export const getStaticPaths = async () => {
return {
paths: [{ params: { id: '1' } }, { params: { id: '2' } }],
fallback: false,
}
}