Skip to content

docs: Workers Cache re-architecture proposal (Chapter 14)#46

Draft
scottmessinger wants to merge 1 commit into
mainfrom
claude/cf-workers-cache-plan-nql92u
Draft

docs: Workers Cache re-architecture proposal (Chapter 14)#46
scottmessinger wants to merge 1 commit into
mainfrom
claude/cf-workers-cache-plan-nql92u

Conversation

@scottmessinger

Copy link
Copy Markdown
Member

What

Adds docs/14-workers-cache-rearchitecture.md (+ index links) — a design proposal for adopting Cloudflare's July 2026 Workers Cache feature. Docs only; no production code changes.

This is a plan for review, not an implementation. It went through three rounds of adversarial subagent review (CloudFlare-platform facts, scaling/fan-out, correctness/protocol/security) and is written to record what survived and what didn't.

The proposal in one paragraph

Model a stream as immutable content-addressed frames + one moving tail, and split the worker into a Gateway entrypoint (auth/CORS/routing, always runs, never cached) in front of a cached Reader WorkerEntrypoint reached via ctx.exports. Auth then always runs before the cache; private streams cache safely keyed on a resolved capability (not the JWT); CORS/X-Cache are applied after the cache (no Vary fragmentation). History is served immutable; massive live fan-out is served by frame-polling with a negatively-cached gap, which decouples DO load from watcher count (O(colos / pollInterval)).

What the adversarial review changed (recorded in the doc)

  • Reads are not actually immutable at a fixed offset today — a binary append >256KB returns different bytes/next-offset/ETag from hot vs R2 storage. The doc makes frame normalization a hard prerequisite, plus a !upToDate cache predicate, a DO-persisted epoch, project-qualified cache keys, and cap hygiene.
  • The real bottleneck (one single-threaded DO per stream) is untouched by a history/auth reframe. Frame-polling is the answer for massive fan-out; low-latency push beyond ~32K watchers/stream is called out as an explicit non-goal needing a relay-DO tree.
  • Silent-failure keying hazards (ctx.props sharding, AuthorizationBYPASS, per-subscriber key fragmentation, unverified cross-colo tiering) are documented; Stage 0 go/no-go is "two JWTs on the same cap → shared HIT on staging."

Status

PROPOSED — gated on Stage 0 staging verification and two sign-off decisions (security boundary; how far to go in one pass). Supersedes Chapters 4–7 if adopted. No code is changed by this PR.

🤖 Generated with Claude Code

https://claude.ai/code/session_015zpKb8VddYgqXP5xygVj5r


Generated by Claude Code

Design proposal for adopting Cloudflare's July 2026 Workers Cache
(per-entrypoint cache via the exports map, ctx.exports caching,
immutable + arbitrary Vary, ctx.cache.purge).

Proposes a Gateway (auth/CORS, always runs) + cached Reader
WorkerEntrypoint split so auth stays in front of the cache, plus
immutable content-addressed frames and frame-polling to decouple DO
load from watcher count. Documents the storage-layer prerequisites
(reads are not immutable at a fixed offset today), the silent-failure
cache-keying hazards (ctx.props sharding, Authorization -> BYPASS,
per-subscriber key fragmentation, unverified cross-colo tiering), and
the relay-DO-tree non-goal for low-latency push beyond ~32K/stream.

Status: PROPOSED — gated on Stage 0 staging verification and two
sign-off decisions. Supersedes Chapters 4-7 if adopted.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015zpKb8VddYgqXP5xygVj5r
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
❌ Deployment failed
View logs
durable-streams-demo-draw bb38102 Jul 06 2026, 04:33 PM

scottmessinger pushed a commit that referenced this pull request Jul 8, 2026
…napshot

The pkg.pr.new tarball for @cloudflare/vitest-pool-workers@11632 was
republished with different content, so pnpm install --frozen-lockfile
failed with ERR_PNPM_TARBALL_INTEGRITY on every CI job (also red on
PR #46). Update the lockfile to the checksum the registry now serves.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WBPrsDvrFACta2rq8qGLVF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants