Files
Josh StoryandGitHub 8cab15c0c9 [Cache Components] Remove unstable prefix from unstable_cacheLife (#84877)
`cacheLife` is now stable and does not require an unstable prefix
2025-10-15 08:14:04 -07:00

29 lines
531 B
TypeScript

import { cacheLife } from 'next/cache'
import { connection } from 'next/server'
import { Suspense } from 'react'
async function Dynamic() {
await connection()
return <p>Dynamic</p>
}
async function getCachedDate() {
'use cache'
cacheLife({ revalidate: 1, expire: 5 * 60 })
return new Date().toISOString()
}
export default async function Page() {
return (
<div>
<Suspense fallback={<p>Loading...</p>}>
<Dynamic />
</Suspense>
<p id="date">{await getCachedDate()}</p>
</div>
)
}