mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
### What? When using a `Request` object with fetch, we'll log a warning indicating that using the `cache` property in addition to `revalidate` is unsupported. ### Why? `Request` sets some defaults on the request init, such as `cache: "default"`. This makes the warning confusing and there's no way to avoid it aside from switching the resource argument to be a URL string instead. ### How? This keeps existing behavior but omits the log in the case where a request object is used and no explicit cache overrides are specified. Fixes #58109
41 lines
714 B
JavaScript
41 lines
714 B
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: 3,
|
|
},
|
|
}
|
|
)
|
|
|
|
await fetch(
|
|
new Request(
|
|
'https://next-data-api-endpoint.vercel.app/api/random?request-input-cache-override',
|
|
{
|
|
cache: 'force-cache',
|
|
}
|
|
),
|
|
{
|
|
next: {
|
|
revalidate: 3,
|
|
},
|
|
}
|
|
)
|
|
|
|
await fetch(
|
|
'https://next-data-api-endpoint.vercel.app/api/random?request-string',
|
|
{
|
|
next: {
|
|
revalidate: 3,
|
|
},
|
|
cache: 'force-cache',
|
|
}
|
|
)
|
|
|
|
return <div>Hello World!</div>
|
|
}
|