Skip to content

Commit 00e3a4b

Browse files
authored
fix: add data request query param to the cache key (#2701)
* fix: vary cache key on __nextDataReq query param * test: update header tests to check for new vary param
1 parent d3d2fb5 commit 00e3a4b

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/run/headers.test.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe('headers', () => {
4040

4141
expect(headers.set).toBeCalledWith(
4242
'netlify-vary',
43-
'header=x-nextjs-data|x-next-debug-logging,cookie=__prerender_bypass|__next_preview_data',
43+
'query=__nextDataReq,header=x-nextjs-data|x-next-debug-logging,cookie=__prerender_bypass|__next_preview_data',
4444
)
4545
})
4646

@@ -56,7 +56,7 @@ describe('headers', () => {
5656

5757
expect(headers.set).toBeCalledWith(
5858
'netlify-vary',
59-
'header=x-nextjs-data|x-next-debug-logging|Accept|Accept-Language,cookie=__prerender_bypass|__next_preview_data',
59+
'query=__nextDataReq,header=x-nextjs-data|x-next-debug-logging|Accept|Accept-Language,cookie=__prerender_bypass|__next_preview_data',
6060
)
6161
})
6262

@@ -77,7 +77,7 @@ describe('headers', () => {
7777

7878
expect(headers.set).toBeCalledWith(
7979
'netlify-vary',
80-
'header=x-nextjs-data|x-next-debug-logging,cookie=__prerender_bypass|__next_preview_data',
80+
'query=__nextDataReq,header=x-nextjs-data|x-next-debug-logging,cookie=__prerender_bypass|__next_preview_data',
8181
)
8282
})
8383

@@ -97,7 +97,7 @@ describe('headers', () => {
9797

9898
expect(headers.set).toBeCalledWith(
9999
'netlify-vary',
100-
'header=x-nextjs-data|x-next-debug-logging,cookie=__prerender_bypass|__next_preview_data',
100+
'query=__nextDataReq,header=x-nextjs-data|x-next-debug-logging,cookie=__prerender_bypass|__next_preview_data',
101101
)
102102
})
103103

@@ -117,7 +117,7 @@ describe('headers', () => {
117117

118118
expect(headers.set).toBeCalledWith(
119119
'netlify-vary',
120-
'header=x-nextjs-data|x-next-debug-logging,language=en|de|fr,cookie=__prerender_bypass|__next_preview_data|NEXT_LOCALE',
120+
'query=__nextDataReq,header=x-nextjs-data|x-next-debug-logging,language=en|de|fr,cookie=__prerender_bypass|__next_preview_data|NEXT_LOCALE',
121121
)
122122
})
123123

@@ -138,7 +138,7 @@ describe('headers', () => {
138138

139139
expect(headers.set).toBeCalledWith(
140140
'netlify-vary',
141-
'header=x-nextjs-data|x-next-debug-logging,language=en|de|fr,cookie=__prerender_bypass|__next_preview_data|NEXT_LOCALE',
141+
'query=__nextDataReq,header=x-nextjs-data|x-next-debug-logging,language=en|de|fr,cookie=__prerender_bypass|__next_preview_data|NEXT_LOCALE',
142142
)
143143
})
144144

@@ -185,7 +185,7 @@ describe('headers', () => {
185185

186186
expect(headers.set).toBeCalledWith(
187187
'netlify-vary',
188-
'query=item_id|page|per_page,header=x-nextjs-data|x-next-debug-logging|x-custom-header,language=en|de|fr|es,cookie=__prerender_bypass|__next_preview_data|NEXT_LOCALE|ab_test,country=es',
188+
'query=__nextDataReq|item_id|page|per_page,header=x-nextjs-data|x-next-debug-logging|x-custom-header,language=en|de|fr|es,cookie=__prerender_bypass|__next_preview_data|NEXT_LOCALE|ab_test,country=es',
189189
)
190190
})
191191
})

src/run/headers.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export const setVaryHeaders = (
8181
header: ['x-nextjs-data', 'x-next-debug-logging'],
8282
language: [],
8383
cookie: ['__prerender_bypass', '__next_preview_data'],
84-
query: [],
84+
query: ['__nextDataReq'],
8585
country: [],
8686
}
8787

0 commit comments

Comments
 (0)