Designing a distributed web performance ·续1

Figure 2: Smart Shield Advanced network diagram
2. Network and optimization (Cloudflare edge)
Once the request reaches the network edge, Cloudflare processes and optimizes the content before it is served or fetched from the cache.
- Traffic Management: The request is inspected. URL Normalization ensures consistency, while Redirect Rules or Transform Rules handle path modifications efficiently. Waiting Room protects the backend during massive traffic surges, maintaining availability.
- Programmatic Customization: For advanced use cases where standard rules are insufficient, Snippets and Workers allow for programmatic customization. This enables executing custom code logic to modify headers, rewrite URLs, image optimizations, or implement unique caching logic directly at the edge. When multiple Workers need to interoperate, use Service Bindings for low-latency, zero-overhead Worker-to-Worker communication. Use the cf.timings.worker_msec Ruleset Engine field to measure wall-clock Worker execution time per request — useful for identifying slow Worker paths, setting up performance-regression alerts, or injecting processing-time headers for downstream observability.
- Content Optimization: Text assets are compressed using Compression Rules (Brotli/Gzip). For significantly greater transfer-size reductions on repeat visits, Shared Dictionaries (beta) let your origin send only the difference between asset versions using
dcb(Dictionary-Compressed Brotli) anddcz(Dictionary-Compressed Zstandard) encodings. In passthrough mode, your origin produces the delta-compressed responses, while Cloudflare forwards the dictionary headers and caches each variant correctly. Browsers without dictionary support continue to receive standard compression. Images are processed on-the-fly via Image Transformations or Polish to ensure they are served in the optimal format (AVIF/WebP) and size for the device, significantly improving LCP and CLS. - Font & Tag Optimization: Cloudflare Fonts eliminates DNS lookups and TLS connections to Google Fonts by serving them inline from the domain. Google Tag Gateway improves ad signal measurement and privacy.
- Routing, Availability & Protocol Intelligence: Cloudflare operates one of the most interconnected networks ↗︎ in the world, peering with over 13,000 networks, operating a global backbone ↗︎, and participating in a leading number of Internet Exchange Points (IXPs) ↗︎ globally. We leverage the unique intelligence ↗︎ derived from this massive dataset to dynamically optimize Congestion Control (CC) at the protocol level - automatically selecting the optimal algorithm and tuning adequate parameters for every connection based on real-time network conditions. For dynamic requests that cannot be cached, Argo Smart Routing finds the fastest path through the network to the origin. Custom Errors provide a consistent brand experience during failures.

Figure 3: Data flow - network and content optimization
3. Tiered Cache and Storage (Cloudflare edge)
Cloudflare can be organized into a specific topology. This layer handles content retention and retrieval. It acts as a shield for the origin and a high-speed store for the client.
- Cache Logic: Origin Cache Control Headers, Cache Rules and Caching Levels allow precise control over TTL and query string handling. Cache Response Rules modify origin responses before they are cached, without changing the origin. Use them to adjust
Cache-Controldirectives, stripSet-Cookieheaders that make static assets uncacheable, set different edge and browser TTLs, or convert another CDN's cache tag header during a migration. For more information, refer to Introducing Cache Response Rules ↗︎. When the origin serves different variants of the same URL (for example, by language or format), enable Vary support in Cache Rules and normalize header values to avoid fragmenting the cache. Implement Cache Normalization strategies to consolidate requests with variable URLs - such as those with distinct marketing or SEO parameters - into a single Cache Key, significantly improving cache hit ratios. Prefetch URLs can pre-populate the cache with critical assets via manifest files to further reduce latency. Asynchronousstale-while-revalidateserves stale content immediately while revalidating in the background, so no visitor waits on the origin after expiry. Note the default caching behavior and limits. - Tiered Caching: If the content is not on the local PoP, Cloudflare checks an upper-tier cache topology. Smart Tiered Caching and Regional Tiered Cache centralize connections, increasing cache hit ratios and reducing global origin load. For origins hosted on public cloud providers (AWS, GCP, Azure, Oracle Cloud), set a cloud region hint so Smart Tiered Cache can select the optimal upper-tier data center for your cloud region, bypassing latency-probing limitations caused by anycast or regional unicast networking. For a more customized approach, Enterprise customers can opt for a Custom Tiered Cache topology.
- Workers Cache: For responses generated by Workers, turn on Workers Cache to serve cached responses without running the Worker. Cache hits skip Worker execution, which reduces latency and CPU usage. Workers Cache is tiered by default and controlled with standard
Cache-Control,Vary, andCache-Tagheaders, with purges issued from code. The cache belongs to the Worker rather than the zone, so zone-level settings such as Cache Rules do not apply. For more information, refer to Your Worker can now have its own cache in front of it ↗︎. - Dedicated long-term Cache: Cache Reserve extends the life of large, infrequently accessed assets (for example, images, archived video, software updates, or static AI models) by moving infrequently accessed content to persistent object storage backend (powered by R2). This prevents eviction due to Least Recently Used (LRU) algorithms and avoids latency-inducing origin fetches, while simultaneously supporting storage redundancy and resilience requirements.
- Instant Purge: Leverage Cloudflare's decentralized purging architecture ↗︎ to invalidate content globally in approximately 150ms. This Instant Purge capability supports various granular approaches - including Purge by URL, Tag, Prefix, or Hostname - ensuring users receive fresh content immediately without waiting for TTL expiration. When only some assets in a group have changed, invalidate instead of purging: content is marked stale and revalidated with the origin, and unchanged assets (
304 Not Modified) are reused rather than downloaded again. This also applies to Cache Reserve content, where a purge forces a full origin fetch. - Cloud Connectivity: Cloud Connector Rules simplify routing traffic to public cloud providers (AWS, Azure, GCP, Oracle Cloud) for specific object storage or origin requirements. For private infrastructure, Workers VPC enables direct connectivity to private storage endpoints or databases on public clouds (for example, AWS, Azure) without exposing them to the public Internet.
- Static Asset Hosting: Entire parts of an application (frontend assets, images, including large media files, software packages) can be stored directly in R2 Object Storage or Workers Static Assets, serving them from the edge without ever hitting a traditional origin server. Additional storage options are available.

Figure 4: Data flow - caching
4. Origin server
For requests that must traverse the full path (that is, dynamic content or cache misses), the origin configuration determines the final latency impact. Architects have two primary paths here: adopting the performant, resilient serverless model (also known as originless), or optimizing connectivity and security for a traditional Origin Server.
Serverless: Cloudflare's Developer Platform achieves the optimal performance tier by enabling an "originless" model. Fullstack applications are built and deployed directly on the global edge network worldwide, eliminating the full path traversal to a distant origin. Dynamic requests execute at the nearest Cloudflare PoP and provide direct access to integrated edge storage solutions like R2 Object Storage and D1 Serverless SQLite Database. With Workers Cache, repeated requests for the same dynamic response are served from cache without running the Worker. This drastically reduces TTFB and contributes significantly to aggressive CWV targets. Furthermore, this Originless model, built on Workers and R2, is the optimal design for high-performance file distribution, eliminating the need for a traditional backend server to deliver large datasets and media.
