Skip to content

Commit 6258af6

Browse files
authored
docs: add missing links and imports to cacheLife and cacheTag for prerender-missing-suspense error (#79247)
One of the important resources for this message is `cacheLife` and `cacheTag`, but the links were missing, and the snippet omitted imports, which newcomers won't know how to import unless looking up.
1 parent 62de494 commit 6258af6

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

errors/next-prerender-missing-suspense.mdx

+10-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ export default async function Page() {
3434
After:
3535

3636
```jsx filename="app/page.js"
37+
import { unstable_cacheTag as cacheTag } from 'next/cache'
38+
import { unstable_cacheLife as cacheLife } from 'next/cache'
39+
3740
async function getRecentArticles() {
3841
"use cache"
3942
// This cache can be revalidated by webhook or server action
@@ -212,13 +215,15 @@ Alternatively you can add a Suspense boundary above the component that is access
212215

213216
### Short-lived Caches
214217

215-
`"use cache"` allows you to describe a `cacheLife()` that might be too short to be practical to prerender. The utility of doing this is that it can still describe a non-zero caching time for the client router cache to reuse the cache entry in the browser and it can also be useful for protecting upstream APIs while experiencing high request traffic.
218+
`"use cache"` allows you to describe a [`cacheLife()`](/docs/app/api-reference/functions/cacheLife) that might be too short to be practical to prerender. The utility of doing this is that it can still describe a non-zero caching time for the client router cache to reuse the cache entry in the browser and it can also be useful for protecting upstream APIs while experiencing high request traffic.
216219

217220
If you expected the `"use cache"` entry to be prerenderable try describing a slightly longer `cacheLife()`.
218221

219222
Before:
220223

221224
```jsx filename="app/page.js"
225+
import { unstable_cacheLife as cacheLife } from 'next/cache'
226+
222227
async function getDashboard() {
223228
"use cache"
224229
// This cache will revalidate after 1 second. It is so short
@@ -237,6 +242,8 @@ export default async function Page() {
237242
After:
238243

239244
```jsx filename="app/page.js"
245+
import { unstable_cacheLife as cacheLife } from 'next/cache'
246+
240247
async function getDashboard() {
241248
"use cache"
242249
// This cache will revalidate after 1 minute. It's long enough that
@@ -260,3 +267,5 @@ Alternatively you can add a Suspense boundary above the component that is access
260267
- [`cookies` function](/docs/app/api-reference/functions/cookies)
261268
- [`draftMode` function](/docs/app/api-reference/functions/draft-mode)
262269
- [`connection` function](/docs/app/api-reference/functions/connection)
270+
- [`cacheLife` function](/docs/app/api-reference/functions/cacheLife)
271+
- [`cacheTag` function](/docs/app/api-reference/functions/cacheTag)

0 commit comments

Comments
 (0)