next.js/test/e2e/app-dir/segment-cache/staleness/app/runtime-stale-2-minutes/page.tsx
page.tsx34 lines780 B
import { Suspense } from 'react'
import { cacheLife } from 'next/cache'
import { cookies } from 'next/headers'

export const unstable_instant = true
export const unstable_prefetch = 'force-runtime'

export default function Page() {
  return (
    <Suspense fallback="Loading...">
      <RuntimePrefetchable />
    </Suspense>
  )
}

async function RuntimePrefetchable() {
  // Prevent this content from appearing in a regular prerender,
  // But allow it to be included in a runtime prefetch.
  await cookies()

  return (
    <Suspense fallback="Loading...">
      <Content />
    </Suspense>
  )
}

async function Content() {
  'use cache'
  await new Promise((resolve) => setTimeout(resolve, 0))
  cacheLife({ stale: 2 * 60 })
  return 'Content with stale time of 2 minutes'
}
Quest for Codev2.0.0
/
SIGN IN