Skip to content

Commit 2962d0b

Browse files
committed
feat: hide 404 caching behind env var
1 parent 81a2338 commit 2962d0b

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/run/headers.ts

+1
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ export const setCacheControlHeaders = (
261261
}
262262

263263
if (
264+
process.env.ENABLE_404_CACHING &&
264265
['GET', 'HEAD'].includes(request.method) &&
265266
!headers.has('cdn-cache-control') &&
266267
!headers.has('netlify-cdn-cache-control')

tests/integration/page-router.test.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,15 @@ test<FixtureTestContext>('Should serve correct locale-aware custom 404 pages', a
154154
).toBe('fr')
155155
})
156156

157-
describe('404 caching', () => {
157+
describe.only('404 caching', () => {
158+
beforeAll(() => {
159+
process.env.ENABLE_404_CACHING = 'true'
160+
})
161+
162+
afterAll(() => {
163+
delete process.env.ENABLE_404_CACHING
164+
})
165+
158166
describe('404 without getStaticProps', () => {
159167
test<FixtureTestContext>('not matching dynamic paths should be cached permanently', async (ctx) => {
160168
await createFixture('page-router', ctx)

0 commit comments

Comments
 (0)