File tree Expand file tree Collapse file tree 20 files changed +1045
-0
lines changed Expand file tree Collapse file tree 20 files changed +1045
-0
lines changed Original file line number Diff line number Diff line change 1+ import { revalidateTag } from 'next/cache'
2+ import { NextRequest } from 'next/server'
3+
4+ export async function GET ( request : NextRequest , { params } ) {
5+ const { slug } = await params
6+
7+ const tagToInvalidate = slug . join ( '/' )
8+
9+ revalidateTag ( tagToInvalidate )
10+
11+ return Response . json ( { tagToInvalidate } )
12+ }
Original file line number Diff line number Diff line change 1+ import { unstable_cacheLife as cacheLife , unstable_cacheTag as cacheTag } from 'next/cache'
2+ import {
3+ BasePageComponentProps ,
4+ getDataImplementation ,
5+ PageComponentImplementation ,
6+ ResultComponentImplementation ,
7+ ResultWrapperComponentProps ,
8+ } from '../../../../../helpers'
9+
10+ async function getData ( route : string ) {
11+ return await getDataImplementation ( route )
12+ }
13+
14+ async function ResultWrapperComponent ( props : ResultWrapperComponentProps ) {
15+ 'use cache'
16+ cacheTag ( `component/${ props . route } ` )
17+ cacheLife ( '1year' )
18+ return < ResultComponentImplementation { ...props } />
19+ }
20+
21+ export default async function PageComponent ( { params } : BasePageComponentProps ) {
22+ return (
23+ < PageComponentImplementation
24+ routeRoot = "default/use-cache-component/dynamic/ttl-1year"
25+ params = { params }
26+ getData = { getData }
27+ ResultWrapperComponent = { ResultWrapperComponent }
28+ />
29+ )
30+ }
31+
32+ export const dynamic = 'force-dynamic'
Original file line number Diff line number Diff line change 1+ import { unstable_cacheLife as cacheLife , unstable_cacheTag as cacheTag } from 'next/cache'
2+ import {
3+ BasePageComponentProps ,
4+ getDataImplementation ,
5+ PageComponentImplementation ,
6+ ResultComponentImplementation ,
7+ ResultWrapperComponentProps ,
8+ } from '../../../../../helpers'
9+
10+ async function getData ( route : string ) {
11+ return await getDataImplementation ( route )
12+ }
13+
14+ async function ResultWrapperComponent ( props : ResultWrapperComponentProps ) {
15+ 'use cache'
16+ cacheTag ( `component/${ props . route } ` )
17+ cacheLife ( '5seconds' )
18+ return < ResultComponentImplementation { ...props } />
19+ }
20+
21+ export default async function PageComponent ( { params } : BasePageComponentProps ) {
22+ return (
23+ < PageComponentImplementation
24+ routeRoot = "default/use-cache-component/dynamic/ttl-5seconds"
25+ params = { params }
26+ getData = { getData }
27+ ResultWrapperComponent = { ResultWrapperComponent }
28+ />
29+ )
30+ }
31+
32+ export const dynamic = 'force-dynamic'
Original file line number Diff line number Diff line change 1+ import { unstable_cacheLife as cacheLife , unstable_cacheTag as cacheTag } from 'next/cache'
2+ import {
3+ BasePageComponentProps ,
4+ generateStaticParamsImplementation ,
5+ getDataImplementation ,
6+ PageComponentImplementation ,
7+ ResultComponentImplementation ,
8+ ResultWrapperComponentProps ,
9+ } from '../../../../../helpers'
10+
11+ async function getData ( route : string ) {
12+ return await getDataImplementation ( route )
13+ }
14+
15+ async function ResultWrapperComponent ( props : ResultWrapperComponentProps ) {
16+ 'use cache'
17+ cacheTag ( `component/${ props . route } ` )
18+ cacheLife ( '10seconds' ) // longer TTL than page revalidate to test interaction
19+ return < ResultComponentImplementation { ...props } />
20+ }
21+
22+ export default async function PageComponent ( { params } : BasePageComponentProps ) {
23+ return (
24+ < PageComponentImplementation
25+ routeRoot = "default/use-cache-component/static/ttl-10seconds"
26+ params = { params }
27+ getData = { getData }
28+ ResultWrapperComponent = { ResultWrapperComponent }
29+ />
30+ )
31+ }
32+
33+ export function generateStaticParams ( ) {
34+ return generateStaticParamsImplementation ( )
35+ }
36+
37+ export const revalidate = 5
38+ export const dynamic = 'force-static'
Original file line number Diff line number Diff line change 1+ import { unstable_cacheLife as cacheLife , unstable_cacheTag as cacheTag } from 'next/cache'
2+ import {
3+ BasePageComponentProps ,
4+ generateStaticParamsImplementation ,
5+ getDataImplementation ,
6+ PageComponentImplementation ,
7+ ResultComponentImplementation ,
8+ ResultWrapperComponentProps ,
9+ } from '../../../../../helpers'
10+
11+ async function getData ( route : string ) {
12+ return await getDataImplementation ( route )
13+ }
14+
15+ async function ResultWrapperComponent ( props : ResultWrapperComponentProps ) {
16+ 'use cache'
17+ cacheTag ( `component/${ props . route } ` )
18+ cacheLife ( '1year' )
19+ return < ResultComponentImplementation { ...props } />
20+ }
21+
22+ export default async function PageComponent ( { params } : BasePageComponentProps ) {
23+ return (
24+ < PageComponentImplementation
25+ routeRoot = "default/use-cache-component/static/ttl-1year"
26+ params = { params }
27+ getData = { getData }
28+ ResultWrapperComponent = { ResultWrapperComponent }
29+ />
30+ )
31+ }
32+
33+ export function generateStaticParams ( ) {
34+ return generateStaticParamsImplementation ( )
35+ }
36+
37+ export const dynamic = 'force-static'
Original file line number Diff line number Diff line change 1+ import { unstable_cacheLife as cacheLife , unstable_cacheTag as cacheTag } from 'next/cache'
2+ import {
3+ BasePageComponentProps ,
4+ getDataImplementation ,
5+ PageComponentImplementation ,
6+ ResultComponentImplementation ,
7+ ResultWrapperComponentProps ,
8+ } from '../../../../../helpers'
9+
10+ async function getData ( route : string ) {
11+ 'use cache'
12+ cacheTag ( `data/${ route } ` )
13+ cacheLife ( '1year' )
14+
15+ return await getDataImplementation ( route )
16+ }
17+
18+ async function ResultWrapperComponent ( props : ResultWrapperComponentProps ) {
19+ return < ResultComponentImplementation { ...props } />
20+ }
21+
22+ export default async function PageComponent ( { params } : BasePageComponentProps ) {
23+ return (
24+ < PageComponentImplementation
25+ routeRoot = "default/use-cache-data/dynamic/ttl-1year"
26+ params = { params }
27+ getData = { getData }
28+ ResultWrapperComponent = { ResultWrapperComponent }
29+ />
30+ )
31+ }
32+
33+ export const dynamic = 'force-dynamic'
Original file line number Diff line number Diff line change 1+ import { unstable_cacheLife as cacheLife , unstable_cacheTag as cacheTag } from 'next/cache'
2+ import {
3+ BasePageComponentProps ,
4+ getDataImplementation ,
5+ PageComponentImplementation ,
6+ ResultComponentImplementation ,
7+ ResultWrapperComponentProps ,
8+ } from '../../../../../helpers'
9+
10+ async function getData ( route : string ) {
11+ 'use cache'
12+ cacheTag ( `data/${ route } ` )
13+ cacheLife ( '5seconds' )
14+
15+ return await getDataImplementation ( route )
16+ }
17+
18+ async function ResultWrapperComponent ( props : ResultWrapperComponentProps ) {
19+ return < ResultComponentImplementation { ...props } />
20+ }
21+
22+ export default async function PageComponent ( { params } : BasePageComponentProps ) {
23+ return (
24+ < PageComponentImplementation
25+ routeRoot = "default/use-cache-data/dynamic/ttl-5seconds"
26+ params = { params }
27+ getData = { getData }
28+ ResultWrapperComponent = { ResultWrapperComponent }
29+ />
30+ )
31+ }
32+
33+ export const dynamic = 'force-dynamic'
Original file line number Diff line number Diff line change 1+ import { unstable_cacheLife as cacheLife , unstable_cacheTag as cacheTag } from 'next/cache'
2+ import {
3+ BasePageComponentProps ,
4+ generateStaticParamsImplementation ,
5+ getDataImplementation ,
6+ PageComponentImplementation ,
7+ ResultComponentImplementation ,
8+ ResultWrapperComponentProps ,
9+ } from '../../../../../helpers'
10+
11+ async function getData ( route : string ) {
12+ 'use cache'
13+ cacheTag ( `data/${ route } ` )
14+ cacheLife ( '10seconds' ) // longer TTL than page revalidate to test interaction
15+
16+ return await getDataImplementation ( route )
17+ }
18+
19+ async function ResultWrapperComponent ( props : ResultWrapperComponentProps ) {
20+ return < ResultComponentImplementation { ...props } />
21+ }
22+
23+ export default async function PageComponent ( { params } : BasePageComponentProps ) {
24+ return (
25+ < PageComponentImplementation
26+ routeRoot = "default/use-cache-data/static/ttl-10seconds"
27+ params = { params }
28+ getData = { getData }
29+ ResultWrapperComponent = { ResultWrapperComponent }
30+ />
31+ )
32+ }
33+
34+ export function generateStaticParams ( ) {
35+ return generateStaticParamsImplementation ( )
36+ }
37+
38+ export const revalidate = 5
39+ export const dynamic = 'force-static'
Original file line number Diff line number Diff line change 1+ import { unstable_cacheLife as cacheLife , unstable_cacheTag as cacheTag } from 'next/cache'
2+ import {
3+ BasePageComponentProps ,
4+ generateStaticParamsImplementation ,
5+ getDataImplementation ,
6+ PageComponentImplementation ,
7+ ResultComponentImplementation ,
8+ ResultWrapperComponentProps ,
9+ } from '../../../../../helpers'
10+
11+ async function getData ( route : string ) {
12+ 'use cache'
13+ cacheTag ( `data/${ route } ` )
14+ cacheLife ( '1year' )
15+
16+ return await getDataImplementation ( route )
17+ }
18+
19+ async function ResultWrapperComponent ( props : ResultWrapperComponentProps ) {
20+ return < ResultComponentImplementation { ...props } />
21+ }
22+
23+ export default async function PageComponent ( { params } : BasePageComponentProps ) {
24+ return (
25+ < PageComponentImplementation
26+ routeRoot = "default/use-cache-data/static/ttl-1year"
27+ params = { params }
28+ getData = { getData }
29+ ResultWrapperComponent = { ResultWrapperComponent }
30+ />
31+ )
32+ }
33+
34+ export function generateStaticParams ( ) {
35+ return generateStaticParamsImplementation ( )
36+ }
37+
38+ export const dynamic = 'force-static'
Original file line number Diff line number Diff line change 1+ import { unstable_cacheLife as cacheLife , unstable_cacheTag as cacheTag } from 'next/cache'
2+ import {
3+ BasePageComponentProps ,
4+ getDataImplementation ,
5+ PageComponentImplementation ,
6+ ResultComponentImplementation ,
7+ ResultWrapperComponentProps ,
8+ } from '../../../../../helpers'
9+
10+ async function getData ( route : string ) {
11+ return await getDataImplementation ( route )
12+ }
13+
14+ async function ResultWrapperComponent ( props : ResultWrapperComponentProps ) {
15+ return < ResultComponentImplementation { ...props } />
16+ }
17+
18+ export default async function PageComponent ( { params } : BasePageComponentProps ) {
19+ 'use cache'
20+ const routeRoot = 'default/use-cache-page/dynamic/ttl-1year'
21+ cacheTag ( `page/${ routeRoot } /${ ( await params ) . slug } ` )
22+ cacheLife ( '1year' )
23+
24+ return (
25+ < PageComponentImplementation
26+ routeRoot = { routeRoot }
27+ params = { params }
28+ getData = { getData }
29+ ResultWrapperComponent = { ResultWrapperComponent }
30+ />
31+ )
32+ }
33+
34+ export const dynamic = 'force-dynamic'
You can’t perform that action at this time.
0 commit comments