Skip to content

Commit 6bd8cd7

Browse files
authored
Ensure we set cache-control: no-cache for actions (#53824)
This ensures we don't accidentally allow caching server actions causing unexpected behavior.
1 parent 0350e00 commit 6bd8cd7

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

packages/next/src/server/app-render/action-handler.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,11 @@ export async function handleAction({
287287
req.method === 'POST'
288288

289289
if (isFetchAction || isURLEncodedAction || isMultipartAction) {
290+
// ensure we avoid caching server actions unexpectedly
291+
res.setHeader(
292+
'Cache-Control',
293+
'no-cache, no-store, max-age=0, must-revalidate'
294+
)
290295
let bound = []
291296

292297
const workerName = 'app' + pathname

0 commit comments

Comments
 (0)