Opt-in ISR for pages that are identical for every user behind Cloudflare Access
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- typescript
- 領域
- backend, performance
調査の方向性
Start with the ISR lookup and response-copy paths named in the issue: void/dist/runtime/routing.mjs and clientRevalidateResponse() in @void/isr; also read the linked cache-bypass and Zero Trust documentation. Trace how credentials, HTML and X-VoidPages responses are handled on MISS, HIT, STALE and background revalidation. Done means the opt-in follows the stated credential, storage and browser-cache rules while preserving Access checks; the issue leaves naming and configuration scope open.
索引モデルが issue の本文から書いたものです。
説明
Summary
Void skips ISR for every request that carries Cookie, Authorization, or (since #335) Cf-Access-Jwt-Assertion (Cache bypass). That is the right default. But it means an app behind Cloudflare Access, including a Void Platform project with Zero Trust protection, can never be served from the ISR cache, even for pages that are the same for everyone Access lets in. The Zero Trust docs already note the cost: "Protected pages render on each request, which can increase latency and request usage." (Caching)
Access decides who may see the app. I'd like a per-path opt-in where the developer states that the response is the same for everyone Access admits, so Void can serve it from the ISR cache once Access has admitted the request. The default would not change.
Use case
A private, annotated collection of statutes behind Access: tens of thousands of pages, a handful of readers, most pages rarely opened. The statute pages are the same for every reader, so we want each page rendered on first request and served from the ISR cache afterwards. Per-user parts (bookmarks, notes, "last read") come from islands that call uncached /api routes, so the cached HTML stays shared. Streaming such parts with defer() would not work, since they would be stored as part of the cached response. output: "static" would render every page on every build, while most pages are never read. Behind Access today, every view renders instead.
What reaches the Worker behind Access
Checked on our production site (workers.dev, protected by Access) with a route that returns only cookie names and header presence: a signed-in browser's request reaches the Worker with the cookies CF_AppSession and CF_Authorization, the headers Cf-Access-Jwt-Assertion and Cf-Access-Authenticated-User-Email, and no Authorization header. Each of these alone is enough to bypass ISR today.
Local reproduction of the current bypass ([email protected], vite preview)
ISR_CACHE was a local KV namespace bound through cloudflare.kv_namespaces, so this is not Cloudflare's edge and not a real Access deployment; Access was simulated by adding its header and cookies by hand. The page is pages/laws/[id].tsx with export const revalidate = 31536000, and its loader returns a render timestamp. Each row shows two requests for the same path:
| Request credentials | 1st | 2nd | Same HTML |
|---|---|---|---|
| none | x-isr-cache: MISS |
HIT |
yes |
Cf-Access-Jwt-Assertion |
no ISR header | no ISR header | no |
Cookie: CF_Authorization=… |
no ISR header | no ISR header | no |
Cookie: CF_AppSession=… |
no ISR header | no ISR header | no |
both Access cookies + Cf-Access-Jwt-Assertion |
no ISR header | no ISR header | no |
Cookie: theme=dark |
no ISR header | no ISR header | no |
Authorization: Bearer … |
no ISR header | no ISR header | no |
A path warmed without credentials was rendered again when requested with both Access cookies and Cf-Access-Jwt-Assertion. Entries are keyed by hostname (127.0.0.1 and localhost each started with MISS). Responses served from the ISR cache carried Cache-Control: public, max-age=0, must-revalidate.
Proposal
The name is a placeholder. The opt-in could sit next to the per-page revalidate export (and, mirroring revalidate, as a routing pattern in void.config.ts):
// pages/laws/[id].server.ts
export const revalidate = 31536000;
export const sharedBehindAccess = true; // placeholder name
What the opt-in means. The whole cached response (layout, embedded loader data and headers included) is the same for every user Access admits, and no authorization beyond Access is needed. The second half matters because a cache hit is served before the app runs: in 1.1.11 the ISR lookup in the Worker's fetch handler comes before app.fetch, so middleware does not run on a hit (void/dist/runtime/routing.mjs). A page that reads the identity, or relies on app middleware to turn some admitted users away, must not opt in.
For a path that opts in:
- Ignored credentials. Void parses the
Cookieheader. If every cookie name isCF_AuthorizationorCF_AppSession(exact names; both are documented on the application hostname in Authorization cookie, and both reach the Worker as shown above) and the only other credential isCf-Access-Jwt-Assertion, the request uses the ISR cache like a public request. Any other cookie, and anyAuthorizationheader, still bypasses the cache. No prefix matching such asCF_*;CF_Bindingis stripped before the origin, andCF_SessionandCF_Devicebelong to the team domain. - Storage rules unchanged. Whether to store is decided on the app's response as today (complete
200only; noSet-Cookie,private,no-store,no-cacheorVaryon request headers;x-revalidate: 0still opts out). - Browser-facing copy is private. For requests that carried Access credentials, the copy sent to the browser gets
Cache-Control: private, no-cacheinstead ofpublic, max-age=0, must-revalidate, onMISS,HIT,STALEand after background revalidation alike. The runtime already builds the stored copy and the client copy separately (clientRevalidateResponse()in@void/isr). - Same boundary for the Pages JSON. The
X-VoidPagesJSON variant follows the same rules as the HTML. - Paths that don't opt in behave exactly as today.
Safety
- Cache hits stay behind the existing checks. On Void Platform, #335 says that dispatch checks the Access JWT again before it serves Worker, static or ISR content; every hit for an opted-in path must keep that order. With direct Cloudflare deploys, Access runs in front of the Worker; this proposal relies on that, does not treat the presence of an Access cookie or header as proof, and does not ask for JWT validation in the Worker.
- No reuse across hostnames. Entries are keyed by hostname, so an entry filled through a protected hostname is never served on another one.
- Identity-read detection is only an aid. Every admitted request carries
Cf-Access-Authenticated-User-Email, so a render can always read the identity. Void could warn in dev, or refuse to store, when a render on an opted-in path reads it, but a hit renders nothing; the developer's statement is what safety rests on. The docs should say so plainly, as #408 does for hand-writtenETags.
Acceptance criteria
- A cache entry filled by admitted user A is served to admitted user B.
- No content is served from the cache to a request that is unauthenticated, carries invalid credentials, or was rejected by Access, even when an entry exists.
- A request with any non-Access cookie or an
Authorizationheader neither reads nor writes the cache. MISS,HIT,STALEand background revalidation apply the same storage rules and the same browser-facing policy.- The
X-VoidPagesJSON variant follows the same boundary as the HTML.
Current workaround and alternatives
We turned ISR off and cache the HTML in our own Cache API middleware. It works, but it loses stale-while-revalidate, per-path TTLs and revalidate({ paths }), and it ignores every credential, not only Access's (in the reproduction it served cached pages to requests with other cookies or Authorization). An Access Bypass policy for those paths would make them public. output: "static" is covered in the use case above.
Open questions
- Naming, and whether the opt-in belongs in a per-page export, in
routing, or both; a single switch may suit an app that sits entirely behind Access. - Cloudflare's edge cookies (
__cf_bm,cf_clearance) on custom domains where Bot Fight Mode or a WAF challenge runs alongside Access.
Environment
[email protected],@void/md, React 19.3.1, Vite 8.3.4, Node.js 24.22.0, pnpm 12.14.0- Production:
void deploy --platform cloudflaretoworkers.dev, protected by Access ("Manage Worker access"). ISR is off there. - Reproduction: local
vite preview(workerd) with a local KV namespace asISR_CACHE.
- 主要言語
- TypeScript
- スター
- 627
- フォーク
- 66
- 平均マージ
- 14時間 38分
- マージ済み PR(30日)
- 179
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
voidzero-dev/void のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
voidzero-dev/void#677 ·
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 30/100
voidzero-dev/void#689 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 52/100
voidzero-dev/void#686 ·
メンテナーはふだん 1 日以内に返信
-
`VoidActionError.message` ignores the server's message, though the docs show it to users対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 52/100
voidzero-dev/void#680 ·
メンテナーはふだん 1 日以内に返信
-
`withValidator({ body })` rejects the multipart bodies that `useForm` and `action()` send for filesオープン
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
voidzero-dev/void#679 ·
メンテナーはふだん 1 日以内に返信
voidzero-dev/void の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
caprover/caprover-frontend#273 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
ai-driven-dev/framework#1147 ·
メンテナーはふだん 1 日以内に返信
-
agent-ui bug p2
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
cybersemics/em#6232 ·
メンテナーはふだん 1 日以内に返信