Mastering Web Cache: A Complete Layered Knowledge System
This article presents a systematic overview of web caching, detailing a seven‑layer cache hierarchy, clarifying the differences between buffer and cache, and explaining key cache metrics and design considerations for modern web architectures.
Introduction
Learning technology systematically is essential; the author extracts and expands the web caching portion from a broader "Web Operations Knowledge System" to form a dedicated "Web Cache Knowledge System" for reference.
Web Cache Knowledge System
In web architecture, layered design is crucial. For a web site, an HTTP request passes through multiple caching layers, which the author organizes into a comprehensive seven‑layer hierarchy.
User Layer: Client‑side caching, primarily browser cache.
Proxy Layer: Mainly CDN services.
Web Layer: Web server caches and opcode caches such as OPCache.
Application Layer: Framework‑level dynamic caching, local caches, and page static‑generation (e.g., e‑commerce product pages).
Data Layer: Distributed caches and database‑internal caches.
System Layer: OS‑level caches covering CPU, memory, and I/O.
Physical Layer: Storage device caches like RAID controller and disk cache (including write cache).
Buffer vs. Cache
Buffer generally serves write operations, while Cache serves read operations. The article uses CPU cache levels (L1, L2, L3) as an example of read caching.
For buffers, a real‑world analogy is a left‑turn waiting zone at an intersection, illustrating how a buffer temporarily holds data (or vehicles) closer to the destination before final write.
In Linux, the "disk buffer" (memory‑based) allows the CPU to consider a write complete while a kernel thread (pdflush) later flushes data to disk, improving overall performance.
Cache‑Related Metrics
Key metrics for web cache design include:
Cache Placement: Client (browser), memory (local or remote), and disk (local or remote).
Cache Expiration: Each cache region has a limited lifetime; expiration can be set per layer.
Forced Expiration: Mechanisms to invalidate cache before its TTL when source data changes.
Cache Hit Rate: The proportion of requests served from cache; higher hit rates yield better performance.
Interview Question
Do cloud services used on mobile phones (cloud contacts, cloud SMS, cloud photos) require a CDN?
Conclusion
Regularly reading technical articles and summarizing them helps solidify knowledge and turn shared insights into personal expertise.
Efficient Ops
This public account is maintained by Xiaotianguo and friends, regularly publishing widely-read original technical articles. We focus on operations transformation and accompany you throughout your operations career, growing together happily.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.