How HTTP Caching Works: Cache-Control, ETags, and CDNs
Learn how HTTP caching works, including Cache-Control, ETags, and CDNs, to improve website performance and reduce latency.

HTTP caching is the backbone of the web, making sites feel fast, reliable, and affordable to run. It slashes latency, reduces server load, and allows infrastructure to withstand sudden spikes in demand. In this guide, we'll explore how HTTP caching works, including Cache-Control, ETags, and CDNs.
What happened
HTTP caching uses headers to control how and when resources are cached. The Cache-Control header is used to specify how long a resource is considered fresh. ETags and Last-Modified headers are used to validate cached resources.
The Cache-Control header has several directives, including max-age, s-maxage, and stale-while-revalidate. These directives control how long a resource is cached and when it should be revalidated.
Why it matters
HTTP caching matters because it can significantly improve website performance. By caching resources, you can reduce the number of requests made to your server, which can reduce latency and improve page load times.
However, caching can also introduce complexity, particularly when dealing with dynamic content. If not implemented correctly, caching can lead to stale content being served to users.
- Improved website performance
- Reduced latency
- Increased scalability
- Complexity in implementing caching
- Potential for stale content
- Need for careful configuration
How to think about it
When implementing HTTP caching, it's essential to consider the types of resources being cached and how they are used. Static assets, such as images and stylesheets, can be cached for longer periods, while dynamic content, such as user data, may require more frequent revalidation.
It's also important to consider the role of CDNs in caching. CDNs can cache resources at edge locations, reducing the distance between users and resources.
FAQ
What is the difference between Cache-Control and ETags?+
Cache-Control is used to specify how long a resource is considered fresh, while ETags are used to validate cached resources.
How do CDNs affect caching?+
CDNs can cache resources at edge locations, reducing the distance between users and resources.
What are some common caching mistakes?+
Common caching mistakes include caching sensitive data, using overly aggressive caching strategies, and failing to revalidate cached resources.
- engineering·4 min readBoosting LLM Performance: Understanding Speculative Decoding for Faster Inference
Explore how speculative decoding accelerates Large Language Model inference, reducing latency and computational costs. This technique is crucial for deploying efficient, real-time AI applications.
- engineering·3 min readNew Outlook Takes 10 Seconds to Open Emails
Microsoft's new Outlook is slower than Outlook Classic
- engineering·2 min readUnderstanding the Critical Rendering Path in Web Browsers
Learn about the critical rendering path and how browsers render web pages.
The week’s highest-signal tech and AI stories, synthesized into a five-minute read. One email a week, no spam, unsubscribe anytime.