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
96d4a79a
Commit
96d4a79a
authored
Oct 28, 2025
by
Zack Tanner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: staleTimes.static should consistently enforce a 30s minimum
parent
94caeadf
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
12 deletions
+15
-12
navigate-reducer.ts
...nt/components/router-reducer/reducers/navigate-reducer.ts
+4
-2
cache.ts
...es/next/src/client/components/segment-cache-impl/cache.ts
+1
-9
segment-cache.ts
packages/next/src/client/components/segment-cache.ts
+8
-0
config-schema.ts
packages/next/src/server/config-schema.ts
+1
-1
config-shared.ts
packages/next/src/server/config-shared.ts
+1
-0
No files found.
packages/next/src/client/components/router-reducer/reducers/navigate-reducer.ts
View file @
96d4a79a
...
...
@@ -15,6 +15,7 @@ import {
navigate
as
navigateUsingSegmentCache
,
NavigationResultTag
,
type
NavigationResult
,
getStaleTimeMs
,
}
from
'../../segment-cache'
// These values are set by `define-env-plugin` (based on `nextConfig.experimental.staleTimes`)
...
...
@@ -22,8 +23,9 @@ import {
export
const
DYNAMIC_STALETIME_MS
=
Number
(
process
.
env
.
__NEXT_CLIENT_ROUTER_DYNAMIC_STALETIME
)
*
1000
export
const
STATIC_STALETIME_MS
=
Number
(
process
.
env
.
__NEXT_CLIENT_ROUTER_STATIC_STALETIME
)
*
1000
export
const
STATIC_STALETIME_MS
=
getStaleTimeMs
(
Number
(
process
.
env
.
__NEXT_CLIENT_ROUTER_STATIC_STALETIME
)
)
export
function
handleExternalUrl
(
state
:
ReadonlyReducerState
,
...
...
packages/next/src/client/components/segment-cache-impl/cache.ts
View file @
96d4a79a
...
...
@@ -93,7 +93,7 @@ import {
DOC_PREFETCH_RANGE_HEADER_VALUE
,
doesExportedHtmlMatchBuildId
,
}
from
'../../../shared/lib/segment-cache/output-export-prefetch-encoding'
import
{
FetchStrategy
}
from
'../segment-cache'
import
{
FetchStrategy
,
getStaleTimeMs
}
from
'../segment-cache'
import
{
createPromiseWithResolvers
}
from
'../../../shared/lib/promise-with-resolvers'
// A note on async/await when working in the prefetch cache:
...
...
@@ -267,14 +267,6 @@ const isOutputExportMode =
process
.
env
.
NODE_ENV
===
'production'
&&
process
.
env
.
__NEXT_CONFIG_OUTPUT
===
'export'
/**
* Ensures a minimum stale time of 30s to avoid issues where the server sends a too
* short-lived stale time, which would prevent anything from being prefetched.
*/
function
getStaleTimeMs
(
staleTimeSeconds
:
number
):
number
{
return
Math
.
max
(
staleTimeSeconds
,
30
)
*
1000
}
// Route cache entries vary on multiple keys: the href and the Next-Url. Each of
// these parts needs to be included in the internal cache key. Rather than
// concatenate the keys into a single key, we use a multi-level map, where the
...
...
packages/next/src/client/components/segment-cache.ts
View file @
96d4a79a
...
...
@@ -162,3 +162,11 @@ export type PrefetchTaskFetchStrategy =
|
FetchStrategy
.
PPR
|
FetchStrategy
.
PPRRuntime
|
FetchStrategy
.
Full
/**
* Ensures a minimum stale time of 30s to avoid issues where the server sends a too
* short-lived stale time, which would prevent anything from being prefetched.
*/
export
function
getStaleTimeMs
(
staleTimeSeconds
:
number
):
number
{
return
Math
.
max
(
staleTimeSeconds
,
30
)
*
1000
}
packages/next/src/server/config-schema.ts
View file @
96d4a79a
...
...
@@ -172,7 +172,7 @@ export const experimentalSchema = {
staleTimes
:
z
.
object
({
dynamic
:
z
.
number
().
optional
(),
static
:
z
.
number
().
optional
(),
static
:
z
.
number
().
gte
(
30
).
optional
(),
})
.
optional
(),
cacheLife
:
z
...
...
packages/next/src/server/config-shared.ts
View file @
96d4a79a
...
...
@@ -299,6 +299,7 @@ export interface ExperimentalConfig {
*/
staleTimes
?:
{
dynamic
?:
number
/** Must be greater than or equal to 30 seconds, to ensure prefetching is not completely wasteful */
static
?:
number
}
/**
...
...
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