Put a site behind Cloudflare
Add a test domain, create DNS records, enable proxying for one subdomain, and verify that traffic flows through Cloudflare edge IPs. Note before/after latency.
Cloud / Knowledge library
edge network for security, speed, and serverless
Cloudflare reduces latency, improves uptime, and blocks attacks by placing security and application logic at a globally distributed edge network. Teams use it to combine CDN, DNS, DDoS protection, WAF, Zero Trust access, and edge/serverless compute in one platform.
Founded in 2009 by Matthew Prince, Michelle Zatlyn, and Lee Holloway. Early growth came from reverse-proxy CDN performance plus DDoS mitigation and security. Became widely adopted for DNS and edge protection in front of web applications. Introduced Cloudflare Workers to run JavaScript/Web API-style serverless code at the edge. Expanded from web acceleration into developer platform, storage, and Zero Trust enterprise networking.
Work through these exercises in order. Try the task before opening a reference.
Add a test domain, create DNS records, enable proxying for one subdomain, and verify that traffic flows through Cloudflare edge IPs. Note before/after latency.
Write a Worker that adds security headers (e.g., X-Content-Type-Options, Referrer-Policy) to all HTML responses without breaking static assets.
Build a GET endpoint with Workers that checks cache first, fetches origin on miss, sets cache headers, and asynchronously writes response to cache using waitUntil.
Protect an internal dashboard with Cloudflare Access using identity provider login and a policy that allows only one team group.
Design a strategy combining WAF rules and application logic to throttle abusive clients while keeping false positives low. Include monitoring KPIs.
A global retail chain managing high-frequency inventory updates across thousands of physical stores and an e-commerce platform.
The business suffers from high latency and database contention when regional store systems attempt to update a centralized origin database, leading to inventory drift and overselling during peak traffic.
By deploying Cloudflare Workers and D1, the business shifts inventory state management to the network edge. Workers intercept incoming update requests at the nearest global point of presence, performing initial validation and state updates against a globally distributed D1 database, which minimizes origin load and ensures local consistency.
This diagram illustrates how client requests are processed at the edge before interacting with the global database.
Store POS or E-commerce App
Global Network Layer
Serverless Execution Logic
Globally Distributed SQL
This code demonstrates how a Worker interacts with a D1 database to perform an atomic inventory update at the edge, mapping directly to the solution of reducing origin load.
export default {
async fetch(request, env) {
// Execute SQL update directly against the edge database
const { results } = await env.DB.prepare(
'UPDATE inventory SET stock = stock - 1 WHERE item_id = ?'
).bind('item_123').run();
return new Response('Inventory updated');
}
};The system achieves significantly lower latency for inventory updates and reduces the direct load on the primary origin infrastructure, resulting in more accurate real-time stock levels.
The primary limitation is eventual consistency across distributed regions; developers must check for potential race conditions or stale reads by implementing appropriate versioning or locking mechanisms within their application logic.