Skip to content

Commit f3436e3

Browse files
committed
Avoid SWR cache-control headers in prerender prefetch tests
1 parent 04d0503 commit f3436e3

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
@@ -1134,7 +1134,9 @@ export const defaultConfig: NextConfig = {
11341134
keepAlive: true,
11351135
},
11361136
logging: {},
1137-
expireTime: 31536000, // one year
1137+
expireTime: process.env.NEXT_PRIVATE_CDN_CONSUMED_SWR_CACHE_CONTROL
1138+
? undefined
1139+
: 31536000, // one year
11381140
staticPageGenerationTimeout: 60,
11391141
output: !!process.env.NEXT_PRIVATE_STANDALONE ? 'standalone' : undefined,
11401142
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)