Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
e75fe68a
Unverified
Commit
e75fe68a
authored
Aug 20, 2025
by
Hendrik Liebau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update directives
parent
42f5931d
Show whitespace changes
Inline
Side-by-side
Showing
30 changed files
with
38 additions
and
38 deletions
+38
-38
page.tsx
.../use-cache/app/(dynamic)/cache-fetch-auth-header/page.tsx
+1
-1
page.tsx
...e2e/app-dir/use-cache/app/(dynamic)/complex-args/page.tsx
+1
-1
page.tsx
...app-dir/use-cache/app/(dynamic)/fetch-revalidate/page.tsx
+1
-1
cached-data.ts
.../use-cache/app/(dynamic)/generate-metadata/cached-data.ts
+1
-1
page.tsx
...pp-dir/use-cache/app/(dynamic)/generate-metadata/page.tsx
+1
-1
page.tsx
test/e2e/app-dir/use-cache/app/(dynamic)/page.tsx
+1
-1
page.tsx
.../use-cache/app/(dynamic)/revalidate-and-redirect/page.tsx
+1
-1
page.tsx
...p-dir/use-cache/app/(dynamic)/revalidate-and-use/page.tsx
+1
-1
page.tsx
...2e/app-dir/use-cache/app/(partially-static)/[id]/page.tsx
+1
-1
route.ts
...e2e/app-dir/use-cache/app/(partially-static)/api/route.ts
+1
-1
page.tsx
...ache/app/(partially-static)/cache-fetch-no-store/page.tsx
+1
-1
page.tsx
...dir/use-cache/app/(partially-static)/cache-fetch/page.tsx
+1
-1
page.tsx
...-dir/use-cache/app/(partially-static)/cache-life/page.tsx
+1
-1
page.tsx
...p-dir/use-cache/app/(partially-static)/cache-tag/page.tsx
+1
-1
page.tsx
...e-cache/app/(partially-static)/draft-mode/[mode]/page.tsx
+3
-3
page.tsx
...2e/app-dir/use-cache/app/(partially-static)/form/page.tsx
+1
-1
cached.ts
...che/app/(partially-static)/imported-from-client/cached.ts
+1
-1
page.tsx
...2e/app-dir/use-cache/app/(partially-static)/logs/page.tsx
+2
-2
cached.ts
...r/use-cache/app/(partially-static)/method-props/cached.ts
+1
-1
page.tsx
.../app/(partially-static)/nested-in-unstable-cache/page.tsx
+1
-1
page.tsx
...p-dir/use-cache/app/(partially-static)/not-found/page.tsx
+1
-1
page.tsx
...ache/app/(partially-static)/on-demand-revalidate/page.tsx
+1
-1
page.tsx
...se-cache/app/(partially-static)/passed-to-client/page.tsx
+3
-3
page.tsx
...e2e/app-dir/use-cache/app/(partially-static)/rdc/page.tsx
+3
-3
page.tsx
...dir/use-cache/app/(partially-static)/react-cache/page.tsx
+1
-1
page.tsx
...ache/app/(partially-static)/referential-equality/page.tsx
+2
-2
page.tsx
...dir/use-cache/app/(partially-static)/rsc-payload/page.tsx
+1
-1
cached.ts
...ache/app/(partially-static)/static-class-method/cached.ts
+1
-1
cached.ts
...e-cache/app/(partially-static)/use-action-state/cached.ts
+1
-1
page.tsx
...-cache/app/(partially-static)/with-server-action/page.tsx
+1
-1
No files found.
test/e2e/app-dir/use-cache/app/(dynamic)/cache-fetch-auth-header/page.tsx
View file @
e75fe68a
...
@@ -2,7 +2,7 @@ import { cookies } from 'next/headers'
...
@@ -2,7 +2,7 @@ import { cookies } from 'next/headers'
import
React
from
'react'
import
React
from
'react'
async
function
getData
()
{
async
function
getData
()
{
'use cache'
'use cache
: remote
'
return
fetch
(
'https://next-data-api-endpoint.vercel.app/api/random'
,
{
return
fetch
(
'https://next-data-api-endpoint.vercel.app/api/random'
,
{
headers
:
{
headers
:
{
...
...
test/e2e/app-dir/use-cache/app/(dynamic)/complex-args/page.tsx
View file @
e75fe68a
async
function
getCached
({
p
})
{
async
function
getCached
({
p
})
{
'use cache'
'use cache
: remote
'
const
array
=
await
p
const
array
=
await
p
if
(
array
instanceof
Uint8Array
)
{
if
(
array
instanceof
Uint8Array
)
{
return
array
[
0
].
toString
(
16
)
+
'-'
+
Math
.
random
()
return
array
[
0
].
toString
(
16
)
+
'-'
+
Math
.
random
()
...
...
test/e2e/app-dir/use-cache/app/(dynamic)/fetch-revalidate/page.tsx
View file @
e75fe68a
import
React
from
'react'
import
React
from
'react'
async
function
getData
()
{
async
function
getData
()
{
'use cache'
'use cache
: remote
'
return
fetch
(
'https://next-data-api-endpoint.vercel.app/api/random'
,
{
return
fetch
(
'https://next-data-api-endpoint.vercel.app/api/random'
,
{
next
:
{
revalidate
:
0
},
next
:
{
revalidate
:
0
},
...
...
test/e2e/app-dir/use-cache/app/(dynamic)/generate-metadata/cached-data.ts
View file @
e75fe68a
import
{
setTimeout
}
from
'timers/promises'
import
{
setTimeout
}
from
'timers/promises'
export
async
function
getCachedData
()
{
export
async
function
getCachedData
()
{
'use cache'
'use cache
: remote
'
await
setTimeout
(
1000
)
await
setTimeout
(
1000
)
return
new
Date
().
toISOString
()
return
new
Date
().
toISOString
()
}
}
test/e2e/app-dir/use-cache/app/(dynamic)/generate-metadata/page.tsx
View file @
e75fe68a
...
@@ -4,7 +4,7 @@ import { getCachedData } from './cached-data'
...
@@ -4,7 +4,7 @@ import { getCachedData } from './cached-data'
export
async
function
generateMetadata
():
Promise
<
Metadata
>
{
export
async
function
generateMetadata
():
Promise
<
Metadata
>
{
// TODO: Deduping with nested caches requires #78703.
// TODO: Deduping with nested caches requires #78703.
// 'use cache'
// 'use cache
: remote
'
await
connection
()
await
connection
()
...
...
test/e2e/app-dir/use-cache/app/(dynamic)/page.tsx
View file @
e75fe68a
import
{
Foo
}
from
'../client'
import
{
Foo
}
from
'../client'
async
function
getCachedRandom
(
x
:
number
,
children
:
React
.
ReactNode
)
{
async
function
getCachedRandom
(
x
:
number
,
children
:
React
.
ReactNode
)
{
'use cache'
'use cache
: remote
'
return
{
return
{
x
,
x
,
y
:
Math
.
random
(),
y
:
Math
.
random
(),
...
...
test/e2e/app-dir/use-cache/app/(dynamic)/revalidate-and-redirect/page.tsx
View file @
e75fe68a
...
@@ -4,7 +4,7 @@ import Link from 'next/link'
...
@@ -4,7 +4,7 @@ import Link from 'next/link'
import
{
connection
}
from
'next/server'
import
{
connection
}
from
'next/server'
async
function
getCachedValue
()
{
async
function
getCachedValue
()
{
'use cache'
'use cache
: remote
'
cacheTag
(
'revalidate-and-redirect'
)
cacheTag
(
'revalidate-and-redirect'
)
return
Math
.
random
()
return
Math
.
random
()
...
...
test/e2e/app-dir/use-cache/app/(dynamic)/revalidate-and-use/page.tsx
View file @
e75fe68a
...
@@ -9,7 +9,7 @@ async function fetchCachedValue() {
...
@@ -9,7 +9,7 @@ async function fetchCachedValue() {
}
}
async
function
getCachedValue
()
{
async
function
getCachedValue
()
{
'use cache'
'use cache
: remote
'
unstable_cacheTag
(
'revalidate-and-use'
)
unstable_cacheTag
(
'revalidate-and-use'
)
return
Math
.
random
()
return
Math
.
random
()
}
}
...
...
test/e2e/app-dir/use-cache/app/(partially-static)/[id]/page.tsx
View file @
e75fe68a
import
{
unstable_cacheLife
}
from
'next/cache'
import
{
unstable_cacheLife
}
from
'next/cache'
async
function
getCachedRandom
(
n
:
number
)
{
async
function
getCachedRandom
(
n
:
number
)
{
'use cache'
'use cache
: remote
'
unstable_cacheLife
(
'weeks'
)
unstable_cacheLife
(
'weeks'
)
return
String
(
Math
.
ceil
(
Math
.
random
()
*
n
))
return
String
(
Math
.
ceil
(
Math
.
random
()
*
n
))
}
}
...
...
test/e2e/app-dir/use-cache/app/(partially-static)/api/route.ts
View file @
e75fe68a
import
{
unstable_cacheTag
}
from
'next/cache'
import
{
unstable_cacheTag
}
from
'next/cache'
async
function
getCachedRandom
()
{
async
function
getCachedRandom
()
{
'use cache'
'use cache
: remote
'
unstable_cacheTag
(
'api'
)
unstable_cacheTag
(
'api'
)
return
Math
.
random
()
return
Math
.
random
()
...
...
test/e2e/app-dir/use-cache/app/(partially-static)/cache-fetch-no-store/page.tsx
View file @
e75fe68a
import
React
from
'react'
import
React
from
'react'
async
function
getData
()
{
async
function
getData
()
{
'use cache'
'use cache
: remote
'
return
fetch
(
return
fetch
(
'https://next-data-api-endpoint.vercel.app/api/random?no-store'
,
'https://next-data-api-endpoint.vercel.app/api/random?no-store'
,
...
...
test/e2e/app-dir/use-cache/app/(partially-static)/cache-fetch/page.tsx
View file @
e75fe68a
import
React
from
'react'
import
React
from
'react'
async
function
getData
()
{
async
function
getData
()
{
'use cache'
'use cache
: remote
'
return
fetch
(
'https://next-data-api-endpoint.vercel.app/api/random'
).
then
(
return
fetch
(
'https://next-data-api-endpoint.vercel.app/api/random'
).
then
(
(
res
)
=>
res
.
text
()
(
res
)
=>
res
.
text
()
...
...
test/e2e/app-dir/use-cache/app/(partially-static)/cache-life/page.tsx
View file @
e75fe68a
import
{
unstable_cacheLife
as
cacheLife
}
from
'next/cache'
import
{
unstable_cacheLife
as
cacheLife
}
from
'next/cache'
async
function
getCachedRandom
()
{
async
function
getCachedRandom
()
{
'use cache'
'use cache
: remote
'
cacheLife
(
'frequent'
)
cacheLife
(
'frequent'
)
return
Math
.
random
()
return
Math
.
random
()
}
}
...
...
test/e2e/app-dir/use-cache/app/(partially-static)/cache-tag/page.tsx
View file @
e75fe68a
...
@@ -9,7 +9,7 @@ async function getCachedWithTag({
...
@@ -9,7 +9,7 @@ async function getCachedWithTag({
tag
:
string
tag
:
string
fetchCache
?:
'force'
|
'revalidate'
fetchCache
?:
'force'
|
'revalidate'
})
{
})
{
'use cache'
'use cache
: remote
'
cacheTag
(
tag
,
'c'
)
cacheTag
(
tag
,
'c'
)
// If `force-cache` or `revalidate` is used for the fetch call, it creates
// If `force-cache` or `revalidate` is used for the fetch call, it creates
...
...
test/e2e/app-dir/use-cache/app/(partially-static)/draft-mode/[mode]/page.tsx
View file @
e75fe68a
...
@@ -5,7 +5,7 @@ async function getCachedValue(
...
@@ -5,7 +5,7 @@ async function getCachedValue(
iterable
:
Iterable
<
number
>
,
iterable
:
Iterable
<
number
>
,
fn
:
()
=>
string
fn
:
()
=>
string
):
Promise
<
[
string
,
()
=>
string
]
>
{
):
Promise
<
[
string
,
()
=>
string
]
>
{
'use cache'
'use cache
: remote
'
// Make sure we're always receiving the arguments the same way, regardless of
// Make sure we're always receiving the arguments the same way, regardless of
// whether draft mode is enabled or not. We're asserting that by checking
// whether draft mode is enabled or not. We're asserting that by checking
...
@@ -27,13 +27,13 @@ export default async function Page({
...
@@ -27,13 +27,13 @@ export default async function Page({
}:
{
}:
{
params
:
Promise
<
{
mode
:
string
}
>
params
:
Promise
<
{
mode
:
string
}
>
})
{
})
{
'use cache'
'use cache
: remote
'
const
{
mode
}
=
await
params
const
{
mode
}
=
await
params
const
offset
=
1000
const
offset
=
1000
const
cachedClosure
=
async
()
=>
{
const
cachedClosure
=
async
()
=>
{
'use cache'
'use cache
: remote
'
return
new
Date
(
Date
.
now
()
+
offset
).
toISOString
()
return
new
Date
(
Date
.
now
()
+
offset
).
toISOString
()
}
}
...
...
test/e2e/app-dir/use-cache/app/(partially-static)/form/page.tsx
View file @
e75fe68a
...
@@ -6,7 +6,7 @@ async function refresh() {
...
@@ -6,7 +6,7 @@ async function refresh() {
}
}
export
default
async
function
Page
()
{
export
default
async
function
Page
()
{
'use cache'
'use cache
: remote
'
cacheTag
(
'home'
)
cacheTag
(
'home'
)
return
(
return
(
...
...
test/e2e/app-dir/use-cache/app/(partially-static)/imported-from-client/cached.ts
View file @
e75fe68a
'use cache'
'use cache
: remote
'
function
getRandomValue
()
{
function
getRandomValue
()
{
const
v
=
Math
.
random
()
const
v
=
Math
.
random
()
...
...
test/e2e/app-dir/use-cache/app/(partially-static)/logs/page.tsx
View file @
e75fe68a
async
function
Bar
()
{
async
function
Bar
()
{
'use cache'
'use cache
: remote
'
const
date
=
new
Date
().
toLocaleTimeString
()
const
date
=
new
Date
().
toLocaleTimeString
()
console
.
log
(
'deep inside'
,
date
)
console
.
log
(
'deep inside'
,
date
)
return
<
p
>
{
date
}
</
p
>
return
<
p
>
{
date
}
</
p
>
}
}
async
function
Foo
()
{
async
function
Foo
()
{
'use cache'
'use cache
: remote
'
console
.
log
(
'inside'
)
console
.
log
(
'inside'
)
return
<
Bar
/>
return
<
Bar
/>
}
}
...
...
test/e2e/app-dir/use-cache/app/(partially-static)/method-props/cached.ts
View file @
e75fe68a
export
function
createCached
(
n
:
number
)
{
export
function
createCached
(
n
:
number
)
{
return
{
return
{
async
getRandomValue
()
{
async
getRandomValue
()
{
'use cache'
'use cache
: remote
'
const
v
=
n
+
Math
.
random
()
const
v
=
n
+
Math
.
random
()
console
.
log
(
v
)
console
.
log
(
v
)
return
v
return
v
...
...
test/e2e/app-dir/use-cache/app/(partially-static)/nested-in-unstable-cache/page.tsx
View file @
e75fe68a
import
{
revalidatePath
,
unstable_cache
}
from
'next/cache'
import
{
revalidatePath
,
unstable_cache
}
from
'next/cache'
async
function
inner
()
{
async
function
inner
()
{
'use cache'
'use cache
: remote
'
return
Math
.
random
()
return
Math
.
random
()
}
}
...
...
test/e2e/app-dir/use-cache/app/(partially-static)/not-found/page.tsx
View file @
e75fe68a
'use cache'
'use cache
: remote
'
import
{
notFound
}
from
'next/navigation'
import
{
notFound
}
from
'next/navigation'
...
...
test/e2e/app-dir/use-cache/app/(partially-static)/on-demand-revalidate/page.tsx
View file @
e75fe68a
...
@@ -2,7 +2,7 @@ import { revalidatePath } from 'next/cache'
...
@@ -2,7 +2,7 @@ import { revalidatePath } from 'next/cache'
import
{
RevalidateButtons
}
from
'./revalidate-buttons'
import
{
RevalidateButtons
}
from
'./revalidate-buttons'
async
function
cachedValue
()
{
async
function
cachedValue
()
{
'use cache'
'use cache
: remote
'
return
Math
.
random
()
return
Math
.
random
()
}
}
...
...
test/e2e/app-dir/use-cache/app/(partially-static)/passed-to-client/page.tsx
View file @
e75fe68a
...
@@ -11,15 +11,15 @@ export default function Page() {
...
@@ -11,15 +11,15 @@ export default function Page() {
return
(
return
(
<
Form
<
Form
foo=
{
async
function
fooNamed
()
{
foo=
{
async
function
fooNamed
()
{
'use cache'
'use cache
: remote
'
return
offset
+
getRandomValue
()
return
offset
+
getRandomValue
()
}
}
}
}
bar=
{
async
function
()
{
bar=
{
async
function
()
{
'use cache'
'use cache
: remote
'
return
offset
+
getRandomValue
()
return
offset
+
getRandomValue
()
}
}
}
}
baz=
{
async
()
=>
{
baz=
{
async
()
=>
{
'use cache'
'use cache
: remote
'
return
offset
+
getRandomValue
()
return
offset
+
getRandomValue
()
}
}
}
}
/>
/>
...
...
test/e2e/app-dir/use-cache/app/(partially-static)/rdc/page.tsx
View file @
e75fe68a
...
@@ -2,17 +2,17 @@ import { connection } from 'next/server'
...
@@ -2,17 +2,17 @@ import { connection } from 'next/server'
import
{
Suspense
}
from
'react'
import
{
Suspense
}
from
'react'
async
function
outermost
(
id
:
string
)
{
async
function
outermost
(
id
:
string
)
{
'use cache'
'use cache
: remote
'
return
id
+
middle
(
'middle'
)
return
id
+
middle
(
'middle'
)
}
}
async
function
middle
(
id
:
string
)
{
async
function
middle
(
id
:
string
)
{
'use cache'
'use cache
: remote
'
return
id
+
innermost
(
'inner'
)
return
id
+
innermost
(
'inner'
)
}
}
async
function
innermost
(
id
:
string
)
{
async
function
innermost
(
id
:
string
)
{
'use cache'
'use cache
: remote
'
return
id
return
id
}
}
...
...
test/e2e/app-dir/use-cache/app/(partially-static)/react-cache/page.tsx
View file @
e75fe68a
...
@@ -10,7 +10,7 @@ function Component() {
...
@@ -10,7 +10,7 @@ function Component() {
}
}
async
function
getCachedComponent
()
{
async
function
getCachedComponent
()
{
'use cache'
'use cache
: remote
'
return
(
return
(
<
div
>
<
div
>
<
p
id=
"a"
>
{
number
()
}
</
p
>
<
p
id=
"a"
>
{
number
()
}
</
p
>
...
...
test/e2e/app-dir/use-cache/app/(partially-static)/referential-equality/page.tsx
View file @
e75fe68a
/* eslint-disable no-self-compare */
/* eslint-disable no-self-compare */
async
function
getObject
(
arg
:
unknown
)
{
async
function
getObject
(
arg
:
unknown
)
{
'use cache'
'use cache
: remote
'
return
{
arg
}
return
{
arg
}
}
}
async
function
getObjectWithBoundArgs
(
arg
:
unknown
)
{
async
function
getObjectWithBoundArgs
(
arg
:
unknown
)
{
async
function
getCachedObject
()
{
async
function
getCachedObject
()
{
'use cache'
'use cache
: remote
'
return
{
arg
}
return
{
arg
}
}
}
...
...
test/e2e/app-dir/use-cache/app/(partially-static)/rsc-payload/page.tsx
View file @
e75fe68a
import
{
ClientComponent
}
from
'./client'
import
{
ClientComponent
}
from
'./client'
async
function
getLargeObject
()
{
async
function
getLargeObject
()
{
'use cache'
'use cache
: remote
'
return
{
hello
:
'world'
}
return
{
hello
:
'world'
}
}
}
...
...
test/e2e/app-dir/use-cache/app/(partially-static)/static-class-method/cached.ts
View file @
e75fe68a
export
class
Cached
{
export
class
Cached
{
static
async
getRandomValue
()
{
static
async
getRandomValue
()
{
'use cache'
'use cache
: remote
'
const
v
=
Math
.
random
()
const
v
=
Math
.
random
()
console
.
log
(
v
)
console
.
log
(
v
)
return
v
return
v
...
...
test/e2e/app-dir/use-cache/app/(partially-static)/use-action-state/cached.ts
View file @
e75fe68a
'use cache'
'use cache
: remote
'
export
async
function
getRandomValue
()
{
export
async
function
getRandomValue
()
{
const
v
=
Math
.
random
()
const
v
=
Math
.
random
()
...
...
test/e2e/app-dir/use-cache/app/(partially-static)/with-server-action/page.tsx
View file @
e75fe68a
...
@@ -7,7 +7,7 @@ async function action() {
...
@@ -7,7 +7,7 @@ async function action() {
}
}
export
default
async
function
Page
()
{
export
default
async
function
Page
()
{
'use cache'
'use cache
: remote
'
return
(
return
(
<
Form
action=
{
action
}
>
<
Form
action=
{
action
}
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment