Insights:Page Caching and CDN Explained in One Diagram
Which Layers Does a Request Pass Through
When a user opens a page, it roughly goes through:
Browser Cache → DNS → CDN Edge Node → Origin / Reverse Proxy → Page Cache → Application → Database
If any layer hits the cache, subsequent layers don't need to repeat the work.
Browser Cache
The browser decides whether to re-download based on response headers:
Cache-Control:How long content can be cached and whether revalidation is needed.ETag/Last-Modified:Whether the content has changed.Expires:Legacy expiration time.
Static assets are suitable for long-term caching; HTML should be handled cautiously. Setting a very long cache for HTML may cause users to keep seeing outdated pages after updates.
Page Cache
Page cache stores "already-generated HTML." Common locations include:
- Reverse proxy or web server.
- Application-level cache.
- Dedicated caching services.
Suitable for:
- Pages that are essentially the same regardless of login status.
- Articles, sections, or product pages with low update frequency.
- Pages that can be explicitly invalidated.
Not suitable for:
- Shopping carts, admin panels, and personalized recommendations.
- Strongly real-time data.
- Pages that vary by user identity.
CDN Edge Cache
CDN places static assets and cacheable HTML at edge nodes. Users visit the edge first, and if there's a hit, the content is returned directly without going back to the origin.
Key configurations:
- Which paths to cache and for how long.
- Which cookies or query parameters affect caching.
- Origin fallback ratio and origin bandwidth.
- Cache invalidation methods and propagation time.
CDN is not "set it and forget it." Misconfigured cache rules can cache login states, prices, or stale pages for all visitors.
How the Three Layers Work Together
| Layer | Primary Purpose | Typical Targets |
|---|---|---|
| Browser Cache | Avoid re-downloading on repeat visits | Images, CSS, JS, fonts |
| Page Cache | Reduce application and database load | Article pages, category pages |
| CDN | Shorten network distance and ease origin server load | Static assets, cacheable HTML |
Diagnostic Sequence
- Check TTFB first to confirm whether the bottleneck is the origin or the network.
- Apply browser caching and CDN to static assets first.
- Evaluate page caching for dynamic pages next.
- Handle authenticated or personalized pages last.
- Change only one layer at a time and keep rollback options ready.
What Not to Do
- Don't set long-cache headers on all HTML.
- Don't cache user-specific content.
- Don't enable CDN and then ignore cache invalidation.
- Don't use CDN to mask slow origin queries.
The goal of caching isn't "maximum hit rate"—it's "right things cached, right things refreshed."
Related Reading: