Skip to content

Commit 0d9526e

Browse files
committed
Avoid SWR cache-control headers in prerender prefetch tests
1 parent 50fd08e commit 0d9526e

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

packages/next/src/server/config-shared.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1129,7 +1129,9 @@ export const defaultConfig: NextConfig = {
11291129
keepAlive: true,
11301130
},
11311131
logging: {},
1132-
expireTime: 31536000, // one year
1132+
expireTime: process.env.NEXT_PRIVATE_CDN_CONSUMED_SWR_CACHE_CONTROL
1133+
? undefined
1134+
: 31536000, // one year
11331135
staticPageGenerationTimeout: 60,
11341136
output: !!process.env.NEXT_PRIVATE_STANDALONE ? 'standalone' : undefined,
11351137
modularizeImports: undefined,

test/production/prerender-prefetch/index.test.ts

+14
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,13 @@ describe('Prerender prefetch', () => {
300300
pages: new FileRef(join(__dirname, 'app/pages')),
301301
},
302302
dependencies: {},
303+
env: {
304+
// Simulate that a CDN has consumed the SWR cache-control header,
305+
// otherwise the browser will cache responses and which messes with
306+
// the expectations in this test.
307+
// See https://github.com/vercel/next.js/pull/70674 for context.
308+
NEXT_PRIVATE_CDN_CONSUMED_SWR_CACHE_CONTROL: '1',
309+
},
303310
})
304311
})
305312
afterAll(() => next.destroy())
@@ -319,6 +326,13 @@ describe('Prerender prefetch', () => {
319326
},
320327
},
321328
dependencies: {},
329+
env: {
330+
// Simulate that a CDN has consumed the SWR cache-control header,
331+
// otherwise the browser will cache responses and which messes with
332+
// the expectations in this test.
333+
// See https://github.com/vercel/next.js/pull/70674 for context.
334+
NEXT_PRIVATE_CDN_CONSUMED_SWR_CACHE_CONTROL: '1',
335+
},
322336
})
323337
})
324338
afterAll(() => next.destroy())

0 commit comments

Comments
 (0)