@@ -448,7 +448,12 @@ describe("fixCacheHeaderForHtmlPages", () => {
448448
449449 it ( "should set cache-control header for /404 page" , ( ) => {
450450 const headers : Record < string , string > = { } ;
451- fixCacheHeaderForHtmlPages ( "/404" , headers ) ;
451+ fixCacheHeaderForHtmlPages (
452+ {
453+ rawPath : "/404" ,
454+ } ,
455+ headers ,
456+ ) ;
452457
453458 expect ( headers [ "cache-control" ] ) . toBe (
454459 "private, no-cache, no-store, max-age=0, must-revalidate" ,
@@ -457,7 +462,12 @@ describe("fixCacheHeaderForHtmlPages", () => {
457462
458463 it ( "should set cache-control header for /500 page" , ( ) => {
459464 const headers : Record < string , string > = { } ;
460- fixCacheHeaderForHtmlPages ( "/500" , headers ) ;
465+ fixCacheHeaderForHtmlPages (
466+ {
467+ rawPath : "/500" ,
468+ } ,
469+ headers ,
470+ ) ;
461471
462472 expect ( headers [ "cache-control" ] ) . toBe (
463473 "private, no-cache, no-store, max-age=0, must-revalidate" ,
@@ -468,7 +478,12 @@ describe("fixCacheHeaderForHtmlPages", () => {
468478 const headers : Record < string , string > = { } ;
469479 config . HtmlPages . push ( "/my-html-page" ) ;
470480
471- fixCacheHeaderForHtmlPages ( "/my-html-page" , headers ) ;
481+ fixCacheHeaderForHtmlPages (
482+ {
483+ rawPath : "/my-html-page" ,
484+ } ,
485+ headers ,
486+ ) ;
472487
473488 expect ( headers [ "cache-control" ] ) . toBe (
474489 "public, max-age=0, s-maxage=31536000, must-revalidate" ,
@@ -482,6 +497,51 @@ describe("fixCacheHeaderForHtmlPages", () => {
482497
483498 expect ( headers ) . not . toHaveProperty ( "cache-control" ) ;
484499 } ) ;
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+ } ) ;
485545} ) ;
486546
487547describe ( "fixSWRCacheHeader" , ( ) => {
0 commit comments