Web Cache Fundamentals and Architecture
What you'll learn: How web caches work, where they sit in the request path, and what determines whether content gets cached—knowledge critical for understanding cache poisoning and other cache-based attacks.
What Is a Web Cache?
A web cache is a temporary storage layer that sits between clients and origin servers, saving copies of responses to speed up future requests. Think of it like a librarian who keeps popular books at the front desk instead of making you walk to the back stacks every time.
Caches reduce server load, lower latency, and save bandwidth—but they also introduce security risks when attackers manipulate what gets cached.
Cache Architecture Layers
Web caching happens at multiple levels:
- Browser cache: Stored locally on your device
- Reverse proxy/CDN cache: Cloudflare, Fastly, Akamai—shared by all users requesting the same content
- Forward proxy cache: Corporate or ISP proxies between users and the internet
Cache Keys and Storage
A cache key determines whether two requests are "the same" and can share a cached response. Typically, caches use the request method (usually GET) and the full URL as the key.
Example cache key: GET https://example.com/page?id=123
However, caches often ignore certain parts of requests:
- HTTP headers (except
Host) - Request body
- Cookies
This selective ignoring creates opportunities for attackers to serve poisoned content to other users.
Cache Storage Mechanisms
Caches decide what to store based on:
- HTTP headers (
Cache-Control,Expires,Vary) - Response status codes (usually 200, 301, 404)
- Content type and size
CDNs like Cloudflare cache static assets aggressively but may cache dynamic content with proper headers, creating unexpected attack surfaces.
Key Takeaway: Web caches store responses using simplified keys (often just method + URL), creating a gap between what the cache sees and what the origin server processes—attackers exploit this gap to poison caches and serve malicious content to victims.