mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
29 lines
531 B
TypeScript
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>
|
|
)
|
|
}
|