Cloudflare
A global network that sits in front of websites and APIs to make them faster and safer, and a platform to run code close to users.
- Type
- CDN, security and edge platform
- Created by
- Cloudflare, Inc.
- Includes
- DNS, CDN, WAF, DDoS protection, Workers, R2 storage
- In my stack
- DNS, caching and protection in front of apps
What it is
When a domain uses Cloudflare, visitors don’t connect to your server directly: they connect to the nearest of Cloudflare’s data centres around the world, which serves cached content right away and forwards the rest to your server. On the way, it handles HTTPS, blocks attacks and filters bad bots.
Beyond that layer, it is a full developer platform: Workers run small JavaScript or TypeScript functions in every data centre, Pages hosts static sites, R2 stores files with no fees for downloading them, and Zero Trust tools protect internal apps without a VPN. Its DNS is one of the fastest available, and the free plan already covers a lot.
Why I use it
Protection from day one. DDoS protection and a web application firewall stop a large share of automated attacks before they reach the server.
Faster for everyone. Images, scripts and pages are served from a city near the visitor, which matters for users far from the server.
The server stays hidden. Visitors only see Cloudflare’s addresses, so the origin server can be locked down to accept traffic from Cloudflare alone.
DNS and certificates in one place. Domains, HTTPS certificates and redirects are managed together, quickly and through an API.
Where I use it
I put Cloudflare in front of public websites and APIs to manage DNS, HTTPS, caching and protection, whether the app itself runs on Vercel, on a server at OVH or on a cluster in Azure. Its firewall complements security testing rather than replacing it: OWASP ZAP finds the holes before release, and Cloudflare filters attacks on the live site. For small jobs at the edge, such as redirects, short links or extra headers, a Worker is often simpler than changing the app.
Best use cases
- Any public website or API that needs fast DNS, HTTPS and basic protection.
- Sites with visitors in several regions, where caching close to users cuts load times.
- APIs exposed to the internet that need rate limiting and bot filtering.
- Small edge functions and static sites with Workers and Pages, and file storage with R2.
When I’d use something else
If an app is internal and only used on a company network, a CDN adds little. When strict rules require all traffic to stay with one cloud provider or in one country, the provider’s own services, such as Azure Front Door, can be the better choice. And a firewall in front never excuses vulnerable code: input still has to be validated in the app.
A small example
A Worker that handles short links at the edge, before the request ever reaches the server. The links are stored in Workers KV.
export default {
async fetch(request, env) {
const url = new URL(request.url);
// Short links are answered at the edge, in the city closest to the visitor
if (url.pathname.startsWith("/go/")) {
const target = await env.LINKS.get(url.pathname.slice(4));
return target
? Response.redirect(target, 302)
: new Response("Not found", { status: 404 });
}
return fetch(request); // everything else goes to the origin server
},
};