@@ -448,7 +448,12 @@ describe("fixCacheHeaderForHtmlPages", () => {
448
448
449
449
it ( "should set cache-control header for /404 page" , ( ) => {
450
450
const headers : Record < string , string > = { } ;
451
- fixCacheHeaderForHtmlPages ( "/404" , headers ) ;
451
+ fixCacheHeaderForHtmlPages (
452
+ {
453
+ rawPath : "/404" ,
454
+ } ,
455
+ headers ,
456
+ ) ;
452
457
453
458
expect ( headers [ "cache-control" ] ) . toBe (
454
459
"private, no-cache, no-store, max-age=0, must-revalidate" ,
@@ -457,7 +462,12 @@ describe("fixCacheHeaderForHtmlPages", () => {
457
462
458
463
it ( "should set cache-control header for /500 page" , ( ) => {
459
464
const headers : Record < string , string > = { } ;
460
- fixCacheHeaderForHtmlPages ( "/500" , headers ) ;
465
+ fixCacheHeaderForHtmlPages (
466
+ {
467
+ rawPath : "/500" ,
468
+ } ,
469
+ headers ,
470
+ ) ;
461
471
462
472
expect ( headers [ "cache-control" ] ) . toBe (
463
473
"private, no-cache, no-store, max-age=0, must-revalidate" ,
@@ -468,7 +478,12 @@ describe("fixCacheHeaderForHtmlPages", () => {
468
478
const headers : Record < string , string > = { } ;
469
479
config . HtmlPages . push ( "/my-html-page" ) ;
470
480
471
- fixCacheHeaderForHtmlPages ( "/my-html-page" , headers ) ;
481
+ fixCacheHeaderForHtmlPages (
482
+ {
483
+ rawPath : "/my-html-page" ,
484
+ } ,
485
+ headers ,
486
+ ) ;
472
487
473
488
expect ( headers [ "cache-control" ] ) . toBe (
474
489
"public, max-age=0, s-maxage=31536000, must-revalidate" ,
@@ -482,6 +497,51 @@ describe("fixCacheHeaderForHtmlPages", () => {
482
497
483
498
expect ( headers ) . not . toHaveProperty ( "cache-control" ) ;
484
499
} ) ;
500
+
501
+ it ( "should add cache-control header for html page with default i18n" , ( ) => {
502
+ const headers : Record < string , string > = { } ;
503
+ config . HtmlPages . push ( "/en/my-html-page" ) ;
504
+ config . NextConfig . i18n = {
505
+ defaultLocale : "en" ,
506
+ locales : [ "en" , "fr" ] ,
507
+ } ;
508
+
509
+ fixCacheHeaderForHtmlPages (
510
+ {
511
+ rawPath : "/my-html-page" ,
512
+ cookies : { } ,
513
+ headers : { } ,
514
+ } ,
515
+ headers ,
516
+ ) ;
517
+
518
+ expect ( headers [ "cache-control" ] ) . toBe (
519
+ "public, max-age=0, s-maxage=31536000, must-revalidate" ,
520
+ ) ;
521
+
522
+ config . NextConfig . i18n = undefined ;
523
+ } ) ;
524
+
525
+ it ( "should add cache-control header for html page with locale" , ( ) => {
526
+ const headers : Record < string , string > = { } ;
527
+ config . HtmlPages . push ( "/en/my-html-page" ) ;
528
+ config . HtmlPages . push ( "/fr/my-html-page" ) ;
529
+
530
+ fixCacheHeaderForHtmlPages (
531
+ {
532
+ rawPath : "/en/my-html-page" ,
533
+ cookies : { } ,
534
+ headers : {
535
+ "accept-language" : "fr" ,
536
+ } ,
537
+ } ,
538
+ headers ,
539
+ ) ;
540
+
541
+ expect ( headers [ "cache-control" ] ) . toBe (
542
+ "public, max-age=0, s-maxage=31536000, must-revalidate" ,
543
+ ) ;
544
+ } ) ;
485
545
} ) ;
486
546
487
547
describe ( "fixSWRCacheHeader" , ( ) => {
0 commit comments