Skip to content

Replace R2 llms-full.txt with fetch from middlecache (build/request time hybrid)#29302

Draft
mvvmm wants to merge 6 commits intoproductionfrom
llms-full-middlecache-build-time
Draft

Replace R2 llms-full.txt with fetch from middlecache (build/request time hybrid)#29302
mvvmm wants to merge 6 commits intoproductionfrom
llms-full-middlecache-build-time

Conversation

@mvvmm
Copy link
Contributor

@mvvmm mvvmm commented Mar 24, 2026

Summary

  • Adds bin/fetch-llms-full.ts that fetches the llms-full.txt tarball from middlecache at build time and extracts per-product files into public/
  • Per-product llms-full.txt files are served as static assets via the ASSETS binding
  • Root /llms-full.txt (~40 MB) exceeds the Workers 25 MiB per-asset limit, so it is excluded from extraction and read from the middlecache R2 bucket at request time via direct binding (same account, no HTTP overhead)
  • Replaces the VENDORED_MARKDOWN R2 binding with a MIDDLECACHE R2 binding pointing to the middlecache bucket

Approach

Build-time static assets + R2 read for root: The prebuild hook downloads llms-full.tar.gz (~15MB) from middlecache and extracts only per-product files into public/{product}/llms-full.txt (96 products). Astro copies these into dist/ and they are served as static assets.

The root llms-full.txt (~40 MB) exceeds the Workers 25 MiB per-asset size limit, so it is excluded from extraction via tar --exclude and the worker reads it from the middlecache R2 bucket at request time via direct binding.

The fetch script follows the same pattern as bin/fetch-skills.ts:

  • Downloads to .tmp/middlecache/ with caching (skips if already present)
  • Supports --soft flag for predev (warns on failure instead of blocking)
  • Supports --force flag to re-fetch
  • Skips extraction if per-product files already exist (idempotent)

This is one of two approaches being tested — compare with #29301 which reads all files from the middlecache R2 bucket at request time.

Tradeoffs vs request-time approach

Build-time (this PR) Request-time (#29301)
Per-product latency Served from edge cache/static assets — fast R2 read at request time
Root llms-full.txt R2 read (same account, direct binding) R2 read (same account, direct binding)
Deploy size +~40MB in static assets No change
Freshness Updated on each deploy Always current
Runtime dependency Middlecache R2 (root file only) Middlecache R2 (all files)

Changes

  • New: bin/fetch-llms-full.ts — Build-time fetch script (excludes root llms-full.txt from extraction)
  • package.json — Added fetch-llms-full to prebuild and predev hooks
  • worker/index.ts — Replaced VENDORED_MARKDOWN R2 read with targeted MIDDLECACHE R2 read for root /llms-full.txt only (per-product files served as static assets)
  • wrangler.toml — Replaced VENDORED_MARKDOWNvendored-markdown binding with MIDDLECACHEmiddlecache binding
  • worker/worker-configuration.d.ts — Replaced VENDORED_MARKDOWN: R2Bucket with MIDDLECACHE: R2Bucket in Env interface
  • .gitignore — Added pattern for extracted per-product llms-full.txt files in public/

Adds bin/fetch-llms-full.ts that downloads the llms-full.txt tarball
from middlecache at prebuild/predev time and extracts it into public/,
where Astro serves the files as static assets.

This removes the VENDORED_MARKDOWN R2 bucket binding and the worker's
llms-full.txt interception — the files are now served directly by the
ASSETS binding like any other static file.
@mvvmm mvvmm requested review from a team and kodster28 as code owners March 24, 2026 22:01
@github-actions
Copy link
Contributor

This pull request requires reviews from CODEOWNERS as it changes files that match the following patterns:

Pattern Owners
* @cloudflare/pcx-technical-writing
*.ts @cloudflare/content-engineering, @kodster28
package.json @cloudflare/content-engineering

@mvvmm mvvmm changed the title Replace R2 llms-full.txt with build-time fetch from middlecache Replace R2 llms-full.txt with fetch from middlecache (build-time) Mar 24, 2026
@mvvmm mvvmm marked this pull request as draft March 24, 2026 22:06
…limit)

The root llms-full.txt is ~40 MB which exceeds the Workers 25 MiB
per-asset size limit. Add it to .assetsignore so it is excluded from
the asset manifest, and proxy it from middlecache at request time.

Per-product llms-full.txt files (all under 4 MB) continue to be
served as static assets.
@mvvmm mvvmm changed the title Replace R2 llms-full.txt with fetch from middlecache (build-time) Replace R2 llms-full.txt with fetch from middlecache (hybrid) Mar 24, 2026
mvvmm added 3 commits March 24, 2026 18:01
Replace the HTTP proxy for root /llms-full.txt with a direct R2 binding
to the middlecache bucket (same account). This eliminates the HTTP
overhead (DNS, TLS, connection) and reads directly via internal IPC.
… limit)

Instead of extracting the root llms-full.txt into public/ and trying to
exclude it via .assetsignore, simply skip it during tar extraction using
--exclude. The root file (~40 MB) exceeds the Workers 25 MiB per-asset
limit and is served from the middlecache R2 bucket at request time.

Only per-product llms-full.txt files (all under 4 MB) are extracted
into public/ and served as static assets.
R2 bindings only work for Workers deployed in the same account. External
contributors running npm run dev locally would get an empty R2 simulation
and 404s for root llms-full.txt. Revert to HTTP fetch from the public
middlecache URL which works for everyone.
@github-actions
Copy link
Contributor

github-actions bot commented Mar 24, 2026

The root llms-full.txt is served at request time from the middlecache
R2 bucket via direct binding (same account, no HTTP overhead). Per-product
files remain static assets from the build.
@mvvmm mvvmm changed the title Replace R2 llms-full.txt with fetch from middlecache (hybrid) Replace R2 llms-full.txt with fetch from middlecache (build/request time hybrid) Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants