mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
`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
96 lines
2.4 KiB
JavaScript
96 lines
2.4 KiB
JavaScript
import Link from 'next/link'
|
|
import { useRouter } from 'next/router'
|
|
|
|
export default function Home() {
|
|
const router = useRouter()
|
|
return (
|
|
<div>
|
|
<p className="title">Home Page</p>
|
|
<div />
|
|
<Link href="/article/foo/bar/123" id="to-article-rewrite">
|
|
to /article/foo/bar/123
|
|
</Link>
|
|
<div />
|
|
<Link href="/rewrite-to-ab-test">A/B test homepage</Link>
|
|
<div />
|
|
<Link
|
|
href="/rewrite-me-to-about?override=internal"
|
|
id="rewrite-me-to-about"
|
|
>
|
|
Rewrite me to about
|
|
</Link>
|
|
<div />
|
|
<Link
|
|
href="/rewrite-to-beforefiles-rewrite"
|
|
id="rewrite-to-beforefiles-rewrite"
|
|
>
|
|
Rewrite me to beforeFiles Rewrite
|
|
</Link>
|
|
<div />
|
|
<Link
|
|
href="/rewrite-to-afterfiles-rewrite"
|
|
id="rewrite-to-afterfiles-rewrite"
|
|
>
|
|
Rewrite me to afterFiles Rewrite
|
|
</Link>
|
|
<div />
|
|
<Link href="/rewrite-me-to-vercel">Rewrite me to Vercel</Link>
|
|
<div />
|
|
<Link href="/rewrite-me-external-twice">
|
|
Redirect me to Vercel (but with double reroutes)
|
|
</Link>
|
|
<div />
|
|
<Link
|
|
href="/rewrite-me-without-hard-navigation?message=refreshed"
|
|
id="link-with-rewritten-url"
|
|
>
|
|
Rewrite me without a hard navigation
|
|
</Link>
|
|
<div />
|
|
<Link href="/about?override=external" id="override-with-external-rewrite">
|
|
Rewrite me to external site
|
|
</Link>
|
|
<div />
|
|
<Link href="/about?override=internal" id="override-with-internal-rewrite">
|
|
Rewrite me to internal path
|
|
</Link>
|
|
<div />
|
|
<Link href="/rewrite-to-static" id="rewrite-to-static">
|
|
Rewrite me to static
|
|
</Link>
|
|
<div />
|
|
<Link href="/fallback-true-blog/rewritten" id="rewrite-to-ssr">
|
|
Rewrite me to /about (SSR)
|
|
</Link>
|
|
<div />
|
|
<Link href="/ssg" id="normal-ssg-link">
|
|
normal SSG link
|
|
</Link>
|
|
<Link href="/dynamic-no-cache/1">/dynamic-no-cache/1</Link>
|
|
<div />
|
|
<a
|
|
href=""
|
|
id="link-to-shallow-push"
|
|
onClick={(e) => {
|
|
e.preventDefault()
|
|
router.push(
|
|
'/?path=rewrite-me-without-hard-navigation&message=refreshed',
|
|
undefined,
|
|
{ shallow: true }
|
|
)
|
|
}}
|
|
>
|
|
Do not rewrite me
|
|
</a>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export function getServerSideProps() {
|
|
return {
|
|
props: {
|
|
now: Date.now(),
|
|
},
|
|
}
|
|
}
|