mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
When using `fetch('', { cache: 'force-cache', { next: { revalidate: 5 } })` on a page that bailed out of ISR, we were effectively ignoring both values and treating the fetch as uncacheable, for several reasons:
- When `cache` and `revalidate` are both specified, we were assuming any combination of the two values is invalid, and we'd unset both the revalidate & fetch configs. In actuality these two properties are only problematic when they convey different caching semantics. This check was modified to instead only warn & unset on conflicting values, specifically `cache: 'no-store` and `revalidate: >0` as well as `cache: 'force-cache'` and `revalidate: 0`.
- When `force-dynamic` was set, we'd opt into no-store behavior on the fetch even if the fetch had an explicit cache config, which is incorrect.
Fixes #71881
65 lines
1.1 KiB
JavaScript
65 lines
1.1 KiB
JavaScript
export const fetchCache = 'default-cache'
|
|
|
|
export default async function Page() {
|
|
await fetch(
|
|
new Request(
|
|
'https://next-data-api-endpoint.vercel.app/api/random?request-input'
|
|
),
|
|
{
|
|
next: {
|
|
revalidate: 0,
|
|
},
|
|
}
|
|
)
|
|
|
|
await fetch(
|
|
new Request(
|
|
'https://next-data-api-endpoint.vercel.app/api/random?request-input-cache-override',
|
|
{
|
|
cache: 'force-cache',
|
|
}
|
|
),
|
|
{
|
|
next: {
|
|
revalidate: 0,
|
|
},
|
|
}
|
|
)
|
|
|
|
await fetch(
|
|
'https://next-data-api-endpoint.vercel.app/api/random?request-string',
|
|
{
|
|
next: {
|
|
revalidate: 0,
|
|
},
|
|
cache: 'force-cache',
|
|
}
|
|
)
|
|
|
|
await fetch(
|
|
new Request(
|
|
'https://next-data-api-endpoint.vercel.app/api/random?no-store-request-input-cache-override',
|
|
{
|
|
cache: 'no-store',
|
|
}
|
|
),
|
|
{
|
|
next: {
|
|
revalidate: 3,
|
|
},
|
|
}
|
|
)
|
|
|
|
await fetch(
|
|
'https://next-data-api-endpoint.vercel.app/api/random?no-store-request-string',
|
|
{
|
|
next: {
|
|
revalidate: 3,
|
|
},
|
|
cache: 'no-store',
|
|
}
|
|
)
|
|
|
|
return <div>Hello World!</div>
|
|
}
|