-
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.
Update cache methods for app dir (#49165)
This ensures we match behavior local and deployed and also cleans up naming of the methods. ---------
- Loading branch information
Showing
14 changed files
with
32 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export { unstable_cache } from 'next/dist/server/web/spec-extension/unstable-cache' | ||
export { unstable_revalidatePath } from 'next/dist/server/web/spec-extension/unstable-revalidate-path' | ||
export { unstable_revalidateTag } from 'next/dist/server/web/spec-extension/unstable-revalidate-tag' | ||
export { revalidatePath } from 'next/dist/server/web/spec-extension/revalidate-path' | ||
export { revalidateTag } from 'next/dist/server/web/spec-extension/revalidate-tag' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// This file is for modularized imports for next/server to get fully-treeshaking. | ||
export { revalidatePath as default } from '../spec-extension/revalidate-path' |
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,2 @@ | ||
// This file is for modularized imports for next/server to get fully-treeshaking. | ||
export { revalidateTag as default } from '../spec-extension/revalidate-tag' |
2 changes: 0 additions & 2 deletions
2
packages/next/src/server/web/exports/unstable-revalidate-path.ts
This file was deleted.
Oops, something went wrong.
2 changes: 0 additions & 2 deletions
2
packages/next/src/server/web/exports/unstable-revalidate-tag.ts
This file was deleted.
Oops, something went wrong.
5 changes: 5 additions & 0 deletions
5
packages/next/src/server/web/spec-extension/revalidate-path.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,5 @@ | ||
import { revalidateTag } from './revalidate-tag' | ||
|
||
export function revalidatePath(path: string) { | ||
return revalidateTag(path) | ||
} |
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
5 changes: 0 additions & 5 deletions
5
packages/next/src/server/web/spec-extension/unstable-revalidate-path.ts
This file was deleted.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
test/e2e/app-dir/app-static/app/api/revalidate-path-edge/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
4 changes: 2 additions & 2 deletions
4
test/e2e/app-dir/app-static/app/api/revalidate-path-node/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
4 changes: 2 additions & 2 deletions
4
test/e2e/app-dir/app-static/app/api/revalidate-tag-edge/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 |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import { NextResponse } from 'next/server' | ||
import { unstable_revalidateTag } from 'next/cache' | ||
import { revalidateTag } from 'next/cache' | ||
|
||
export const revalidate = 0 | ||
export const runtime = 'edge' | ||
|
||
export async function GET(req) { | ||
const tag = req.nextUrl.searchParams.get('tag') | ||
unstable_revalidateTag(tag) | ||
revalidateTag(tag) | ||
return NextResponse.json({ revalidated: true, now: Date.now() }) | ||
} |
4 changes: 2 additions & 2 deletions
4
test/e2e/app-dir/app-static/app/api/revalidate-tag-node/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 |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import { NextResponse } from 'next/server' | ||
import { unstable_revalidateTag } from 'next/cache' | ||
import { revalidateTag } from 'next/cache' | ||
|
||
export const revalidate = 0 | ||
|
||
export async function GET(req) { | ||
const tag = req.nextUrl.searchParams.get('tag') | ||
unstable_revalidateTag(tag) | ||
revalidateTag(tag) | ||
return NextResponse.json({ revalidated: true, now: Date.now() }) | ||
} |