Cloudflare moved cdnjs, 9 billion daily requests, onto its edge
· Do Minh Tuan · Developer Corner 💻
Cloudflare says it has moved cdnjs entirely onto its own Developer Platform. cdnjs is one of the open-source repositories the web quietly leans on for JavaScript and CSS packages, and it serves around 9 billion requests a day. The whole publishing and delivery path now runs on Workers, R2 object storage, KV, Queues and Containers instead of traditional backend servers.
On paper that sounds like a routine infrastructure story, and I am suspicious of routine. Static files, a CDN, a migration. Fine.
In practice, this is the kind of project I would lose sleep over, because it goes wrong in a way users notice. cdnjs is not one site. It is a dependency for an enormous number of other sites, many of which will break in strange ways if a single byte changes.
Why this migration is harder than it looks
Every package URL has to stay the same. Every file has to stay byte-identical. And every Subresource Integrity hash has to match, because browsers check that hash before they will run a script.
SRI is the tamper check: the page says 'this file should hash to this value', and the browser refuses anything that does not. That is good security, and it is a hard constraint during a migration. One stray newline in a minified file and thousands of sites start failing, with an error message that looks like a broken website rather than a broken CDN.
So the interesting claim is that every URL, file and hash survived the move. That is a statement about process discipline, not about serverless being fast.
Where the real work sits
Delivery of static assets is the part everyone can picture: put the file close to the user, serve it from cache, done. The hard part is ingestion. New package versions arrive constantly, and each one needs to be accepted, validated, stored and indexed before anyone can fetch it.
Cloudflare split that work using Queues, which is a managed message queue. Instead of a web server doing validation and compression inside the request, the request drops a job into the queue and the heavy work happens in the background. When a popular package publishes a release and traffic spikes, the queue absorbs the burst instead of falling over.
That pattern is worth stealing regardless of your stack. Any pipeline where a user action triggers slow processing, from image uploads to report generation, benefits from the same separation. Accept the job quickly, do the work asynchronously, and let the queue be the shock absorber.
Versioned assets should be cached forever. The header Cloudflare describes, public, max-age 31536000 with immutable, tells browsers and caches they never need to revalidate that exact file. If the file ever changes, the version in the name changes too. That is how you get both long cache lifetimes and instant updates.
The trap is putting the version in a query string and expecting proxies to honour it. Immutable URLs are the whole trick. A CDN cannot rescue a naming scheme that reuses the same path for different content.
One more pattern from the write-up that I would apply anywhere: keep static payloads out of your application containers. If your API server is also storing and serving assets, it can never scale cleanly or restart without risk. Object storage for files, compute for logic. That separation is old advice and it is still the advice.
What I am skeptical about
Zero egress fees is a genuinely useful property of R2, and it is also a competitive argument from the company that sells it. When a vendor publishes a migration story that ends with 'and this is why our platform is good', read the architecture and discount the conclusion.
The part I would want to see before trusting the story is the rollback plan. If the new ingestion path misses a package, or produces a file that fails validation, I would want to know who gets paged and how quickly a bad release gets pulled. A migration that went smoothly once does not prove the operational path is safe.
I would also want to know how the integrity check is verified on the way in, not just on the way out. If a package is published upstream with a bad hash, you want to reject it at ingestion, not discover it from users.
Few companies serve 9 billion requests a day, and most do not need this architecture. What they do have is a bill for servers that sit idle most of the day and spike for a few hours, plus a maintenance burden that grows every year. What I would copy is the separation, not the scale.
Moving static media and simple endpoints to an edge platform changes the shape of that bill and the shape of the on-call rota. You stop paying for idle capacity and start paying for work done. The trade is real, though: edge platforms come with their own limits, their own debugging story, and their own lock-in. I would move the boring parts first, like images and landing pages, and keep the parts with complicated state where the team already knows how to operate them.
For a team in Vietnam serving users in the US, Europe and Singapore, the latency argument is the one that actually matters. Physical distance is the one cost you cannot optimise away in code. Serving from a location near the user is usually cheaper than making the request faster.
The lesson I take is that the constraint matters more than the headline.
If I were running a migration of something other people depend on, I would write down what must not change before touching a header: the URLs, the hashes, the response codes. Then I would make those invariants part of the test suite, not part of a checklist someone reads once. That is the part I would copy, and it does not require a nine-figure infrastructure budget.
Written with AI assistance, reviewed and edited by Do Minh Tuan.