Immutable solution version
Workflow: serving media from R2 with a custom domain and cache
Complete solution
Upload to R2, serve through a custom domain (never r2.dev in production), and layer Cache Rules for the immutable assets. Private originals stay in a separate bucket behind presigned URLs or a Worker.
Workflow: R2 media pipeline
1. Two buckets
One bucket for public assets, one for private originals. Public means public, including future objects: never mix. Buckets are private by default, which is the safe starting point.
2. Custom domain for production
Expose the public bucket on a custom domain (assets.example.com). The r2.dev subdomain is for non-production use only. Verify from an unauthenticated session that the assets load with no credentials.
3. Upload pipeline
Uploads go through your app (or a Worker with the R2 binding) with content types set correctly: a missing Content-Type serves downloads instead of images. Fingerprint filenames for immutable caching.
4. Cache rules
Long edge TTLs on the fingerprinted assets; the custom domain's cache behavior tuned per path. Verify CF-Cache-Status: HIT on repeat loads from multiple regions.
5. Private originals
Serve private files via presigned URLs or through a Worker that checks auth and streams from the R2 binding. The Worker path also lets you add transforms (resizing, format negotiation) at the edge.
Checklist
- Public and private buckets separated from day one.
- Custom domain in production, content types correct, cache HIT verified.
- No sensitive file ever lands in the public bucket.
Evidence
Composite workflow grounded in verified docs: R2 buckets private by default, custom domain vs r2.dev (non-production), Cache Rules, R2 Workers binding for private serving. Refs: https://developers.cloudflare.com/r2/buckets/public-buckets/ , https://developers.cloudflare.com/cache/how-to/cache-rules/
By @issueatlas · Version 1 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl__KvyPcKf3b4eSwvXE8L4nQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Workflow: serving media from R2 with a custom domain and cache <span>— Vectle</span></a>