@@ -609,8 +609,11 @@ describe('server', () => {
609
609
const res = await get ( '/articles/deleting-a-team' , { followRedirects : false } )
610
610
expect ( res . statusCode ) . toBe ( 302 )
611
611
expect ( res . headers [ 'set-cookie' ] ) . toBeUndefined ( )
612
- // no cache control because a language prefix had to be injected
613
- expect ( res . headers [ 'cache-control' ] ) . toBe ( 'private, no-store' )
612
+ // language specific caching
613
+ expect ( res . headers [ 'cache-control' ] ) . toContain ( 'public' )
614
+ expect ( res . headers [ 'cache-control' ] ) . toMatch ( / m a x - a g e = [ 1 - 9 ] / )
615
+ expect ( res . headers . vary ) . toContain ( 'accept-language' )
616
+ expect ( res . headers . vary ) . toContain ( 'x-user-language' )
614
617
} )
615
618
616
619
test ( 'redirects old articles to their slugified URL' , async ( ) => {
@@ -625,8 +628,12 @@ describe('server', () => {
625
628
const res = await get ( '/' )
626
629
expect ( res . statusCode ) . toBe ( 302 )
627
630
expect ( res . headers . location ) . toBe ( '/en' )
628
- expect ( res . headers [ 'cache-control' ] ) . toBe ( 'private, no-store' )
629
631
expect ( res . headers [ 'set-cookie' ] ) . toBeUndefined ( )
632
+ // language specific caching
633
+ expect ( res . headers [ 'cache-control' ] ) . toContain ( 'public' )
634
+ expect ( res . headers [ 'cache-control' ] ) . toMatch ( / m a x - a g e = [ 1 - 9 ] / )
635
+ expect ( res . headers . vary ) . toContain ( 'accept-language' )
636
+ expect ( res . headers . vary ) . toContain ( 'x-user-language' )
630
637
} )
631
638
632
639
// This test exists because in a previous life, our NextJS used to
@@ -644,8 +651,12 @@ describe('server', () => {
644
651
645
652
expect ( res . statusCode ) . toBe ( 302 )
646
653
expect ( res . headers . location ) . toBe ( '/en' )
647
- expect ( res . headers [ 'cache-control' ] ) . toBe ( 'private, no-store' )
648
654
expect ( res . headers [ 'set-cookie' ] ) . toBeUndefined ( )
655
+ // language specific caching
656
+ expect ( res . headers [ 'cache-control' ] ) . toContain ( 'public' )
657
+ expect ( res . headers [ 'cache-control' ] ) . toMatch ( / m a x - a g e = [ 1 - 9 ] / )
658
+ expect ( res . headers . vary ) . toContain ( 'accept-language' )
659
+ expect ( res . headers . vary ) . toContain ( 'x-user-language' )
649
660
} )
650
661
651
662
test ( 'redirects / to /en when unsupported language preference is specified' , async ( ) => {
@@ -658,17 +669,24 @@ describe('server', () => {
658
669
} )
659
670
expect ( res . statusCode ) . toBe ( 302 )
660
671
expect ( res . headers . location ) . toBe ( '/en' )
661
- expect ( res . headers [ 'cache-control' ] ) . toBe ( 'private, no-store' )
662
672
expect ( res . headers [ 'set-cookie' ] ) . toBeUndefined ( )
673
+ // language specific caching
674
+ expect ( res . headers [ 'cache-control' ] ) . toContain ( 'public' )
675
+ expect ( res . headers [ 'cache-control' ] ) . toMatch ( / m a x - a g e = [ 1 - 9 ] / )
676
+ expect ( res . headers . vary ) . toContain ( 'accept-language' )
677
+ expect ( res . headers . vary ) . toContain ( 'x-user-language' )
663
678
} )
664
679
665
680
test ( 'adds English prefix to old article URLs' , async ( ) => {
666
681
const res = await get ( '/articles/deleting-a-team' )
667
682
expect ( res . statusCode ) . toBe ( 302 )
668
683
expect ( res . headers . location . startsWith ( '/en/' ) ) . toBe ( true )
669
684
expect ( res . headers [ 'set-cookie' ] ) . toBeUndefined ( )
670
- // no cache control because a language prefix had to be injected
671
- expect ( res . headers [ 'cache-control' ] ) . toBe ( 'private, no-store' )
685
+ // language specific caching
686
+ expect ( res . headers [ 'cache-control' ] ) . toContain ( 'public' )
687
+ expect ( res . headers [ 'cache-control' ] ) . toMatch ( / m a x - a g e = [ 1 - 9 ] / )
688
+ expect ( res . headers . vary ) . toContain ( 'accept-language' )
689
+ expect ( res . headers . vary ) . toContain ( 'x-user-language' )
672
690
} )
673
691
674
692
test ( 'redirects that not only injects /en/ should have cache-control' , async ( ) => {
0 commit comments