[PR #777] [MERGED] fix: emit no-store Cache-Control for revalidate = 0 pages #836

Closed
opened 2026-05-06 13:10:24 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/777
Author: @NathanDrake2406
Created: 4/4/2026
Status: Merged
Merged: 4/4/2026
Merged by: @james-elicx

Base: mainHead: fix/cache-control-revalidate-zero


📝 Commits (1)

  • 48354be fix: emit no-store Cache-Control for revalidate = 0 pages

📊 Changes

2 files changed (+80 additions, -4 deletions)

View changed files

📝 packages/vinext/src/server/app-page-response.ts (+20 -4)
📝 tests/app-page-response.test.ts (+60 -0)

📄 Description

Summary

  • Pages with export const revalidate = 0 were not getting a Cache-Control header, allowing CDNs to cache them
  • 0 is falsy in JS — the RSC function used if (options.revalidateSeconds) and the HTML function used revalidateSeconds > 0, both silently skipping the zero case
  • Added explicit === 0 checks in both resolveAppPageRscResponsePolicy and resolveAppPageHtmlResponsePolicy, placed before any branch that would mishandle 0 as falsy
  • Also tightened the isForceStatic/isDynamicError condition in the HTML helper from (=== null || === 0) to === null, removing the now-unreachable dead branch
  • Next.js treats revalidate = 0 as equivalent to dynamic = "force-dynamic" for caching: emits Cache-Control: no-store, must-revalidate

Test plan

  • New unit tests for revalidateSeconds: 0 in both RSC and HTML policy functions, including isForceStatic: true + revalidateSeconds: 0 combination to verify priority ordering
  • All existing response policy tests still pass (15 total)
  • pnpm run check passes

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/cloudflare/vinext/pull/777 **Author:** [@NathanDrake2406](https://github.com/NathanDrake2406) **Created:** 4/4/2026 **Status:** ✅ Merged **Merged:** 4/4/2026 **Merged by:** [@james-elicx](https://github.com/james-elicx) **Base:** `main` ← **Head:** `fix/cache-control-revalidate-zero` --- ### 📝 Commits (1) - [`48354be`](https://github.com/cloudflare/vinext/commit/48354beb9065a6dbe6bd654e50c89bba63bc3687) fix: emit no-store Cache-Control for revalidate = 0 pages ### 📊 Changes **2 files changed** (+80 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/server/app-page-response.ts` (+20 -4) 📝 `tests/app-page-response.test.ts` (+60 -0) </details> ### 📄 Description ## Summary - Pages with `export const revalidate = 0` were not getting a `Cache-Control` header, allowing CDNs to cache them - `0` is falsy in JS — the RSC function used `if (options.revalidateSeconds)` and the HTML function used `revalidateSeconds > 0`, both silently skipping the zero case - Added explicit `=== 0` checks in both `resolveAppPageRscResponsePolicy` and `resolveAppPageHtmlResponsePolicy`, placed before any branch that would mishandle `0` as falsy - Also tightened the `isForceStatic/isDynamicError` condition in the HTML helper from `(=== null || === 0)` to `=== null`, removing the now-unreachable dead branch - Next.js treats `revalidate = 0` as equivalent to `dynamic = "force-dynamic"` for caching: emits `Cache-Control: no-store, must-revalidate` ## Test plan - [ ] New unit tests for `revalidateSeconds: 0` in both RSC and HTML policy functions, including `isForceStatic: true` + `revalidateSeconds: 0` combination to verify priority ordering - [ ] All existing response policy tests still pass (15 total) - [ ] `pnpm run check` passes --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 13:10:24 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vinext#836
No description provided.