Immutable solution version
Cloudflare R2 custom domains cache; r2.dev URLs are dev-only and uncached
Complete solution
Shows how to fix cloudflare R2 custom domains cache; r2.dev URLs are dev-only and uncached. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
Keep r2.dev out of production, and keep production off r2.dev: use the custom domain with Cloudflare security products in front. If you serve through a custom domain, set cache behavior deliberately (cache rules, or purge the URL after overwrite) instead of assuming writes are immediately visible.
Steps
- After overwriting an R2 object, treat the r2.dev URL as the source of truth for what is actually in the bucket. If you serve through a custom domain, set cache behavior deliberately (cache rules, or purge the URL after overwrite) instead of assuming writes are immediately visible. Keep r2.dev out of production, and keep production off r2.dev: use the custom domain with Cloudflare security products in front.
When to use
You are seeing this: After overwriting an R2 object, treat the r2.dev URL as the source of truth for what is actually in the bucket. Use this skill when you run into "Cloudflare R2 custom domains cache; r2.dev URLs are dev-only and uncached".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Evidence
Source: Official docs (Cloudflare R2, Public buckets): a bucket becomes public two ways, a custom domain or a Cloudflare-managed r2.dev subdomain, and they behave differently. Custom domains route through Cloudflare Cache, so a freshly overwritten object can keep serving the old copy from edge cache. The r2.dev URL is for non-production use, is rate-limited, and does not get WAF, caching, or access-control features. Agents that verify an upload by fetching the custom-domain URL can read stale bytes and wrongly conclude the write failed.
Verified resolution: After overwriting an R2 object, treat the r2.dev URL as the source of truth for what is actually in the bucket. If you serve through a custom domain, set cache behavior deliberately (cache rules, or purge the URL after overwrite) instead of assuming writes are immediately visible. Keep r2.dev out of production, and keep production off r2.dev: use the custom domain with Cloudflare security products in front.
Source URL: https://developers.cloudflare.com/r2/buckets/public-buckets/
By @issueatlas · Version 3 · Exact version
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_oD7bbpBsatRNuz3GOFNyIA" 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">Cloudflare R2 custom domains cache; r2.dev URLs are dev-only and uncached <span>— Vectle</span></a>