Caching explained in plain terms means keeping a copy of something expensive to produce, so the next person who asks for it gets the copy instead of making it again. The central question is why the web feels instant when every page is built on distant computers, and the short answer is that most of what you see was already fetched, stored nearby, and served again without a fresh trip to the origin server.
Every time you open a familiar website, you are probably looking at cached copies. The logo, the style sheet, the fonts, and often the page itself were saved somewhere between the server and your screen the first time they were requested. The second visit skips most of the work, which is why it feels so much faster than the first.
Caching is not a single technology. It is a pattern that appears at every layer of the web, from the memory inside your browser to the vast networks of servers that deliver video around the world. The idea is always the same, even though the machinery changes, and understanding it explains a surprising amount of how the modern internet behaves.
Key takeaways
- Caching stores a copy of data close to where it is needed, so repeat requests are answered without rebuilding it.
- Every layer of the web caches, from browsers and content delivery networks to servers and databases.
- A cache entry is useful only while it is fresh, so every cached copy carries an expiry time.
- Stale caches cause outdated pages, which is why clearing a cache sometimes fixes a broken site.
- Good caching trades a little freshness for a large gain in speed and lower server load.
What caching is
A cache is a store of copies kept somewhere fast and close at hand. When a system needs a piece of data, it checks the cache first. If the copy is there and still fresh, it is used straight away; if it is not there, the system fetches the original, uses it, and usually stores a copy for next time.
The trick is that fetching the original is slow or expensive, while reading the copy is quick and cheap. A web page might take a database query, several file reads, and a template render to build, yet serving the finished page from memory takes almost no time at all. Caching turns a slow, repeated job into a fast lookup.
This is not a new idea, and it is not limited to computers. A librarian who keeps the most requested books on a shelf by the desk is caching. A cook who prepares a sauce in advance for the dinner rush is caching, and computers simply apply the same logic at a scale and speed that no human could match.
How a cache decides what to keep
No cache can hold everything, so every cache has rules about what to store, how long to keep it, and what to throw away when space runs out. The most common rule is to keep what was used most recently, on the reasonable assumption that something asked for a moment ago will be asked for again soon.
Every cached copy also carries a lifetime, known as its time to live. A news homepage might be cached for a minute, a logo for a year. When the lifetime expires, the copy is treated as stale, and the next request fetches a fresh version, balancing speed against freshness.
Some caches check back with the origin before serving a copy, asking whether anything has changed. If nothing has changed, the origin says so, and the cached copy is served with a renewed lifetime. This check is far cheaper than fetching the whole page again, and it keeps content fresh without giving up the speed of the cache.
Caches also need a way to remove copies on demand. When an editor publishes a correction to an article, the site must tell its caches to drop the old version, a process called invalidation. A cache that cannot be invalidated will keep serving the old page until its lifetime expires, which is one reason updates sometimes take a while to appear.

Where caching happens
Your browser is the first cache you meet. It stores images, style sheets, scripts, and sometimes whole pages on your own device, following instructions the server sends with each response. When you return to a site, the browser serves much of the page from its own store and asks the server only for what has changed.
Content delivery networks, known as CDNs, are the next layer. A CDN keeps copies of a site’s files on servers all over the world, and serves each visitor from the nearest one. A reader in London and a reader in Sydney both get fast pages, because neither has to wait for data to cross the planet from a single origin server.
Servers cache too. A busy site may keep the finished HTML of its most popular pages in memory, so it can serve them instantly instead of rebuilding them for every visitor. More advanced setups store the results of database queries or fragments of pages, such as a navigation menu that rarely changes, and assemble pages from these ready-made pieces.
Databases have their own caches as well, keeping the most queried rows and the results of recent queries in memory, because reading from memory is far faster than reading from disk. Our guide to database indexing explains the related trick of organising data so the database can find the right rows quickly in the first place. Specialised stores such as Redis exist largely to act as fast, shared caches for applications, and our guide to Redis explains how that in-memory store is used.
Caching compared
| Cache type | Where it lives | What it stores | Typical lifetime |
|---|---|---|---|
| Browser cache | On your device | Images, styles, scripts, pages | Days to a year |
| CDN cache | Servers worldwide | Static files and pages | Minutes to days |
| Server cache | On the web server | Finished pages and fragments | Seconds to hours |
| Database cache | In database memory | Query results and rows | Seconds to minutes |
| Application cache | In a store like Redis | Computed results and sessions | Minutes to hours |
The benefits, and the catch
The benefit that matters most is speed. A page served from a nearby cache can arrive in tens of milliseconds, where a full rebuild might take a second or more. On a slow mobile connection, that difference decides whether a visitor stays or leaves, and search engines pay attention to it too.
Caching also protects the origin server. When a page goes viral, the flood of requests hits the caches, which absorb most of it, while the origin sees only a fraction. Without caching, the same flood would overwhelm the server, and the site would fall over at exactly the moment everyone wanted to read it.
The catch is staleness. A cached copy is, by definition, a snapshot of the past, and it can be wrong, since prices change, headlines are corrected, and stock runs out, yet the cache keeps serving the old version until its lifetime ends or it is invalidated. Every caching decision is therefore a trade: how much freshness are you willing to give up for speed?
There is also a cost in complexity, since caches add another layer that can fail, confuse, or behave unexpectedly. A developer who cannot see why a change is not appearing is often fighting a cache somewhere in the chain, and the fix is usually to clear it or to wait. That frustration is the price of the speed everyone else enjoys.
Caching checklist
- Cache static files such as images and style sheets for a long time, with a versioned filename.
- Keep dynamic pages cached briefly, so they stay fresh without rebuilding on every visit.
- Set clear expiry times on every response, and never rely on a default you have not checked.
- Invalidate cached copies the moment the underlying content changes.
- Use a CDN so visitors are served from a server near them, not from one far away.
- Cache database results for queries that run often and change rarely.
- Measure the cache hit rate, and investigate when it falls without an obvious cause.
- Test the site with a cold cache, not only a warm one, so you see what new visitors see.
- Clear the cache deliberately after a deployment, rather than waiting for old copies to expire.
Frequently asked questions
What is caching in simple terms?
Caching means saving a copy of something so it can be reused quickly. When you visit a website, parts of the page are stored near you, and the next visit reuses those copies instead of fetching everything again from the original server.
Why is caching important?
Caching makes the web fast and keeps servers from being overwhelmed. Without it, every page view would require a full rebuild and a long journey across the internet, and popular sites would collapse under the load of their own success.
What is the difference between a browser cache and a CDN?
A browser cache lives on your own device and stores files for your visits alone. A CDN is a network of servers around the world that stores copies for every visitor, serving each person from the server nearest to them.
Why do I sometimes see an old version of a website?
You are probably seeing a cached copy whose lifetime has not yet expired. The site has changed, but a cache somewhere between the server and your screen is still serving the old version. Clearing your browser cache or waiting usually fixes it.
Does caching affect SEO?
Yes, indirectly but importantly. Faster pages rank better and keep visitors engaged, and caching is one of the most effective ways to make pages faster. Search engines measure page speed, so a well-cached site has a real advantage.
When should you not cache something?
Never cache anything personal or unique to one visitor, such as an account page, a shopping basket, or a checkout. Those pages must be built fresh for each person, or one visitor could be shown another visitor’s private information.
The bottom line
Caching explained in one line is this: keep a copy close to hand, serve it quickly, and refresh it before it goes stale.
It is the reason the web feels instant, the reason popular sites survive their busiest days, and the reason a page sometimes shows yesterday’s news. Learn where the caches sit and how long they keep their copies, and much of the web’s behaviour starts to make sense.
This article is general information about how caching works, not advice about which caching setup suits a particular website.







