@@ -82,6 +82,7 @@ import { buildAppStaticPaths } from './static-paths/app'
82
82
import { buildPagesStaticPaths } from './static-paths/pages'
83
83
import type { PrerenderedRoute } from './static-paths/types'
84
84
import type { CacheControl } from '../server/lib/cache-control'
85
+ import { formatCacheControl } from './output/format'
85
86
86
87
export type ROUTER_TYPE = 'pages' | 'app'
87
88
@@ -347,7 +348,6 @@ export interface PageInfo {
347
348
*/
348
349
isRoutePPREnabled : boolean
349
350
ssgPageRoutes : string [ ] | null
350
- // TODO: initialCacheControl should be set per prerendered route.
351
351
initialCacheControl : CacheControl | undefined
352
352
pageDuration : number | undefined
353
353
ssgPageDurations : number [ ] | undefined
@@ -447,7 +447,9 @@ export async function printTreeView(
447
447
// Collect all the symbols we use so we can print the icons out.
448
448
const usedSymbols = new Set ( )
449
449
450
- const messages : [ string , string , string ] [ ] = [ ]
450
+ const messages : [ string , string , string , string ] [ ] = [ ]
451
+
452
+ let showCacheLife = false
451
453
452
454
const stats = await computeFromManifest (
453
455
{ build : buildManifest , app : appBuildManifest } ,
@@ -468,12 +470,17 @@ export async function printTreeView(
468
470
return
469
471
}
470
472
473
+ showCacheLife = filteredPages . some (
474
+ ( page ) => pageInfos . get ( page ) ?. initialCacheControl ?. revalidate
475
+ )
476
+
471
477
messages . push (
472
478
[
473
479
routerType === 'app' ? 'Route (app)' : 'Route (pages)' ,
474
480
'Size' ,
475
481
'First Load JS' ,
476
- ] . map ( ( entry ) => underline ( entry ) ) as [ string , string , string ]
482
+ showCacheLife ? 'Cache Life' : '' ,
483
+ ] . map ( ( entry ) => underline ( entry ) ) as [ string , string , string , string ]
477
484
)
478
485
479
486
filteredPages . forEach ( ( item , i , arr ) => {
@@ -522,16 +529,8 @@ export async function printTreeView(
522
529
523
530
usedSymbols . add ( symbol )
524
531
525
- // TODO: Rework this to be usable for app router routes.
526
- // See https://vercel.slack.com/archives/C02CDC2ALJH/p1739552318644119?thread_ts=1739550179.439319&cid=C02CDC2ALJH
527
- if ( pageInfo ?. initialCacheControl ?. revalidate ) usedSymbols . add ( 'ISR' )
528
-
529
532
messages . push ( [
530
- `${ border } ${ symbol } ${
531
- pageInfo ?. initialCacheControl ?. revalidate
532
- ? `${ item } (ISR: ${ pageInfo ?. initialCacheControl . revalidate } Seconds)`
533
- : item
534
- } ${
533
+ `${ border } ${ symbol } ${ item } ${
535
534
totalDuration > MIN_DURATION
536
535
? ` (${ getPrettyDuration ( totalDuration ) } )`
537
536
: ''
@@ -550,6 +549,9 @@ export async function printTreeView(
550
549
? getPrettySize ( pageInfo . totalSize , { strong : true } )
551
550
: ''
552
551
: '' ,
552
+ showCacheLife && pageInfo ?. initialCacheControl
553
+ ? formatCacheControl ( pageInfo . initialCacheControl )
554
+ : '' ,
553
555
] )
554
556
555
557
const uniqueCssFiles =
@@ -569,6 +571,7 @@ export async function printTreeView(
569
571
`${ contSymbol } ${ innerSymbol } ${ getCleanName ( file ) } ` ,
570
572
typeof size === 'number' ? getPrettySize ( size ) : '' ,
571
573
'' ,
574
+ '' ,
572
575
] )
573
576
} )
574
577
}
@@ -623,6 +626,10 @@ export async function printTreeView(
623
626
routes . forEach (
624
627
( { route, duration, avgDuration } , index , { length } ) => {
625
628
const innerSymbol = index === length - 1 ? '└' : '├'
629
+
630
+ const initialCacheControl =
631
+ pageInfos . get ( route ) ?. initialCacheControl
632
+
626
633
messages . push ( [
627
634
`${ contSymbol } ${ innerSymbol } ${ route } ${
628
635
duration > MIN_DURATION
@@ -635,6 +642,9 @@ export async function printTreeView(
635
642
} `,
636
643
'' ,
637
644
'' ,
645
+ showCacheLife && initialCacheControl
646
+ ? formatCacheControl ( initialCacheControl )
647
+ : '' ,
638
648
] )
639
649
}
640
650
)
@@ -653,6 +663,7 @@ export async function printTreeView(
653
663
? getPrettySize ( sharedFilesSize , { strong : true } )
654
664
: '' ,
655
665
'' ,
666
+ '' ,
656
667
] )
657
668
const sharedCssFiles : string [ ] = [ ]
658
669
const sharedJsChunks = [
@@ -686,14 +697,20 @@ export async function printTreeView(
686
697
return
687
698
}
688
699
689
- messages . push ( [ ` ${ innerSymbol } ${ cleanName } ` , getPrettySize ( size ) , '' ] )
700
+ messages . push ( [
701
+ ` ${ innerSymbol } ${ cleanName } ` ,
702
+ getPrettySize ( size ) ,
703
+ '' ,
704
+ '' ,
705
+ ] )
690
706
} )
691
707
692
708
if ( restChunkCount > 0 ) {
693
709
messages . push ( [
694
710
` └ other shared chunks (total)` ,
695
711
getPrettySize ( restChunkSize ) ,
696
712
'' ,
713
+ '' ,
697
714
] )
698
715
}
699
716
}
@@ -705,7 +722,7 @@ export async function printTreeView(
705
722
list : lists . app ,
706
723
} )
707
724
708
- messages . push ( [ '' , '' , '' ] )
725
+ messages . push ( [ '' , '' , '' , '' ] )
709
726
}
710
727
711
728
pageInfos . set ( '/404' , {
@@ -735,17 +752,18 @@ export async function printTreeView(
735
752
. map ( gzipSize ? fsStatGzip : fsStat )
736
753
)
737
754
738
- messages . push ( [ '' , '' , '' ] )
755
+ messages . push ( [ '' , '' , '' , '' ] )
739
756
messages . push ( [
740
757
'ƒ Middleware' ,
741
758
getPrettySize ( sum ( middlewareSizes ) , { strong : true } ) ,
742
759
'' ,
760
+ '' ,
743
761
] )
744
762
}
745
763
746
764
print (
747
765
textTable ( messages , {
748
- align : [ 'l' , 'l ' , 'r' ] ,
766
+ align : [ 'l' , 'r' , 'r ', 'r' ] ,
749
767
stringLength : ( str ) => stripAnsi ( str ) . length ,
750
768
} )
751
769
)
@@ -766,19 +784,13 @@ export async function printTreeView(
766
784
'(SSG)' ,
767
785
`prerendered as static HTML (uses ${ cyan ( staticFunctionInfo ) } )` ,
768
786
] ,
769
- usedSymbols . has ( 'ISR' ) && [
770
- '' ,
771
- '(ISR)' ,
772
- `incremental static regeneration (uses revalidate in ${ cyan (
773
- staticFunctionInfo
774
- ) } )`,
775
- ] ,
776
787
usedSymbols . has ( '◐' ) && [
777
788
'◐' ,
778
789
'(Partial Prerender)' ,
779
790
'prerendered as static HTML with dynamic server-streamed content' ,
780
791
] ,
781
792
usedSymbols . has ( 'ƒ' ) && [ 'ƒ' , '(Dynamic)' , `server-rendered on demand` ] ,
793
+ showCacheLife && [ '' , '(Cache Life)' , 'revalidate / expire' ] ,
782
794
] . filter ( ( x ) => x ) as [ string , string , string ] [ ] ,
783
795
{
784
796
align : [ 'l' , 'l' , 'l' ] ,
0 commit comments