A cache is a small, fast store of copies of data that has been used recently, kept so it can be reused quickly. Instead of fetching or working something out again from scratch, a computer checks the cache first. If the answer is already there, things load faster.
How it works
Getting data can be slow. It may have to come from a server on the other side of the world, from a large storage drive, or from a calculation that takes time. A cache keeps a copy of the result somewhere quicker to reach, closer to where it is needed.
When a program needs something, it looks in the cache first. If the item is there, this is called a cache hit, and the program uses the copy straight away. If it isn’t, it’s a cache miss: the program gets the data the slow way, then usually saves a copy in the cache for next time.
Caches are small compared with the original source, so they can’t keep everything. They need rules for what to throw away when they fill up. A common approach is to remove the item that hasn’t been used for the longest time. Many caches also give each copy an expiry time, so old information is refreshed rather than shown forever.
Caches exist at many levels. Your computer’s processor has tiny caches built into the chip. Your web browser keeps a cache of images and files from sites you visit. Websites use caches on their servers, and many use content delivery networks, which keep copies of pages on servers in different regions so visitors get them from somewhere nearby.
An everyday example
Think of a kitchen. You keep salt, oil and the pans you use every day on the counter, and the rarely used items in a cupboard. The counter is your cache. It doesn’t hold everything, but it holds the things you reach for most, so cooking is quicker.
Your web browser does the same thing. The first time you visit a site, it downloads the logo, the fonts and the styling. The next time, it can reuse its stored copies instead of downloading them again, so the page appears faster.
Why it matters
Caching is one of the main reasons the web feels fast. It cuts waiting time for users, reduces the work servers have to do, and saves data, which matters on slow or expensive connections.
The catch is that a cache can hold out-of-date copies. If a website changes but your browser or a server keeps showing the old version, you see something that is no longer true. That’s why “clear your cache” is such a common fix when a page looks wrong or doesn’t update after a change.
Because of this, the people who build websites and apps have to decide how long each kind of data can safely be cached. A company logo might be kept for weeks, because it rarely changes. A news headline or the number of items left in stock might be kept for only a few seconds, or not cached at all, because an old copy could mislead people.
Common questions
Is it safe to clear my browser cache?
Yes. It only removes stored copies. The browser will download fresh ones as you visit sites again, so pages may load a little more slowly at first.
Is a cache the same as cookies?
No. A cache stores copies of files and data to speed things up. Cookies are small notes a website saves to remember things about you, such as whether you are signed in.
Why does a site still look old after it was updated?
Usually because a cache somewhere, in your browser or on the site’s servers, is still serving the earlier copy. Refreshing the page or clearing the cache normally fixes it.
Related terms
- Browser
- Cookie
- Server
- Content delivery network (CDN)
- Cloud computing