-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'canary' into elef/introduce-error-builder
- Loading branch information
Showing
9 changed files
with
371 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
test/production/app-dir/fetch-cache/app/api/revalidate/route.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { revalidateTag } from 'next/cache' | ||
import { NextRequest, NextResponse } from 'next/server' | ||
|
||
export const dynamic = 'force-dynamic' | ||
|
||
export function GET(req: NextRequest) { | ||
revalidateTag('thankyounext') | ||
return NextResponse.json({ done: true }) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { ReactNode } from 'react' | ||
export default function Root({ children }: { children: ReactNode }) { | ||
return ( | ||
<html> | ||
<body>{children}</body> | ||
</html> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { unstable_cache } from 'next/cache' | ||
|
||
export const dynamic = 'force-dynamic' | ||
export const fetchCache = 'default-cache' | ||
|
||
const getCachedRandom = unstable_cache( | ||
async () => { | ||
return Math.random() | ||
}, | ||
[], | ||
{ | ||
revalidate: 3, | ||
tags: ['thankyounext'], | ||
} | ||
) | ||
|
||
export default async function Page() { | ||
const data = await fetch( | ||
'https://next-data-api-endpoint.vercel.app/api/random?a=b', | ||
{ next: { tags: ['thankyounext'], revalidate: 3 } } | ||
).then((res) => res.text()) | ||
|
||
const cachedRandom = getCachedRandom() | ||
|
||
return ( | ||
<> | ||
<p>hello world</p> | ||
<p id="data">{data}</p> | ||
<p id="random">{cachedRandom}</p> | ||
</> | ||
) | ||
} |
Oops, something went wrong.