Skip to content

Commit c367c72

Browse files
Disable cache for rsc pages (vercel#33438)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
1 parent 45eb137 commit c367c72

File tree

2 files changed

+13
-0
lines changed
  • packages/next/build/webpack/loaders/next-middleware-ssr-loader
  • test/integration/react-streaming-and-server-components/test

2 files changed

+13
-0
lines changed

packages/next/build/webpack/loaders/next-middleware-ssr-loader/render.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { toNodeHeaders } from '../../../../server/web/utils'
66
const createHeaders = (args?: any) => ({
77
...args,
88
'x-middleware-ssr': '1',
9+
'Cache-Control': 'no-cache, no-store, max-age=0, must-revalidate',
910
})
1011

1112
function sendError(req: any, error: Error) {

test/integration/react-streaming-and-server-components/test/index.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,18 @@ async function runBasicTests(context, env) {
357357
expect(pathNotFoundHTML).toContain(page404Content)
358358
})
359359

360+
it('should disable cache for RSC pages', async () => {
361+
const urls = ['/', '/next-api/image', '/next-api/link']
362+
await Promise.all(
363+
urls.map(async (url) => {
364+
const { headers } = await fetchViaHTTP(context.appPort, url)
365+
expect(headers.get('cache-control')).toBe(
366+
'no-cache, no-store, max-age=0, must-revalidate'
367+
)
368+
})
369+
)
370+
})
371+
360372
it('should support next/link', async () => {
361373
const linkHTML = await renderViaHTTP(context.appPort, '/next-api/link')
362374
const $ = cheerio.load(linkHTML)

0 commit comments

Comments
 (0)