What is a browser cache? How it speeds up websites
Where your browser stores copies of images, scripts and fonts, why cached pages load faster, and how to clear the cache or force a fresh copy.
On this page
- How the browser cache works
- What gets stored in the cache
- Why a cached page can look outdated
- How to clear the browser cache
- Browser cache vs cookies
- Browser cache vs CDN cache
- FAQ
- What is the difference between no-cache and no-store?
- Does clearing the browser cache also log me out of websites?
- What is the difference between a hard reload and clearing the cache?
- Why does my browser still load a file even though the server set a long max-age?
- Summary
A browser cache is the storage on your device where your browser keeps copies of the files it has downloaded — images, stylesheets, scripts and fonts. When you visit a site again, the browser can reuse those local copies instead of downloading everything over the network again, which is why repeat visits feel almost instant.
How the browser cache works
Every request your browser makes is first routed to the cache to check for a valid stored response. If there is a match, the resource is read from the cache: no network round-trip, no data usage, no waiting. The browser only contacts the server when the cached copy is missing or out of date.
Each stored response has a lifetime. A fresh entry can be used without contacting the server at all. Once a response becomes stale, the browser must validate it: it sends a small conditional request to the server, asking "has this file changed?". If the file is unchanged, the server replies 304 Not Modified and the cached copy is reused without downloading the file again. That validation round-trip is far cheaper than re-downloading the whole resource.
What gets stored in the cache
The typical cache contents are static assets that rarely change:
- Images (JPEG, PNG, WebP, SVG)
- Stylesheets (CSS)
- JavaScript files
- Fonts
- Sometimes HTML pages, when the server allows it
Websites use cache headers to control what is stored and for how long. The two most common mechanisms:
Cache-Control— the server states how long a file may be reused, for examplemax-age=31536000(one year). Theno-storedirective forbids caching,no-cachemeans "store it, but always check with the server before reusing".ETag/Last-Modified— validation tokens.ETagis a fingerprint of the file content; when the browser validates, the server compares tokens and answers304 Not Modifiedif nothing changed.
Because the browser cache is private to your device, it can also store personalized responses (for example a page tailored to your account) without leaking them to other users.
Why a cached page can look outdated
If a website releases a new design but a visitor still sees the old one, a stale cached file is usually the cause. The fix is a hard reload, which bypasses the cache and re-downloads everything from the server:
- Windows / Linux:
Ctrl + F5(orCtrl + Shift + R) - macOS:
Cmd + Shift + R
Developers avoid this problem with cache busting: they change the file name whenever content changes (for example styles-a1b2.css instead of styles.css), so browsers treat it as a new file.
How to clear the browser cache
Clearing the cache removes the stored copies, not your passwords or logged-in sessions:
- Open the browser settings (or the history menu).
- Find "Clear browsing data" (Chrome, Edge), "Clear history and website data" (Firefox), or the equivalent in Safari.
- Select "Cached images and files" (leave cookies and site data alone unless you want to log out).
You can also set the time range to "All time" for a full wipe. If a site still misbehaves after clearing, a hard reload usually finishes the job.
Browser cache vs cookies
The cache and cookies are different systems that often get mixed up. The cache stores files (images, scripts) and makes sites load faster. Cookies store small pieces of data about you (logins, preferences) and are sent to the server with each request. Clearing the cache does not log you out or delete your preferences; clearing cookies does. That is why "clear the cache" fixes broken-looking pages, while "clear cookies" fixes login and personalization problems.
Browser cache vs CDN cache
The browser cache runs on your device. A CDN runs a similar idea at a much larger scale: shared caches on servers around the world that serve the same files to many users. The two work together — the CDN makes the first visit fast from anywhere, and the browser cache makes repeat visits fast on your own device.
FAQ
What is the difference between no-cache and no-store?
no-store tells the browser and any intermediate cache not to store the response at all — every request goes back to the server. no-cache looks similar but actually means "you may store it, but you must revalidate with the server before reusing the stored copy". With no-cache you still save the file; you just do not reuse it without checking. That is why no-store is the right choice for sensitive data, while no-cache is the right choice for content that changes often.
Does clearing the browser cache also log me out of websites?
No, not by itself. Logins live in cookies, not in the cache. Clearing only "Cached images and files" keeps cookies and site data intact, so you stay signed in. You only get logged out when you also clear cookies, site data, or active sessions. This separation is exactly why "clear the cache" fixes broken-looking pages while "clear cookies" fixes login and personalization problems.
What is the difference between a hard reload and clearing the cache?
A hard reload (Ctrl + F5 / Cmd + Shift + R) bypasses the cache for the current page only and forces the browser to fetch every file again. Clearing the cache removes the stored files for all sites and stays in effect until they are downloaded again. Use a hard reload when one page looks stale; use "clear browsing data" when the problem affects many sites or persists across reloads.
Why does my browser still load a file even though the server set a long max-age?
Because the cache is a best-effort store. Browsers may evict entries to reclaim disk space, private browsing windows often use a separate cache that is wiped on close, and users can clear the cache at any time. A long max-age makes the file last as long as the browser keeps it, not forever — that is why servers pair Cache-Control with an ETag or Last-Modified so a re-downloaded copy can still be validated cheaply.
Summary
The browser cache is a local copy of the files a website needs, reused on later visits to save time and bandwidth. Servers control it with Cache-Control and validation headers, developers bust stale versions with changing file names, and you can always force a fresh copy with a hard reload or by clearing the cache in your browser settings.
Sources
- MDN — HTTP caching (developer.mozilla.org/en-US/docs/Web/HTTP/Caching)
- web.dev — HTTP caching (web.dev/articles/http-cache)
Share this guide
Related guides
- How browser cookies work: a plain guide
What cookies are, how session and tracking cookies differ, and what 'accept all cookies' actually means.
- What is Server-Side Rendering (SSR)? How it works and when to use it
Server-side rendering generates the full HTML for a page on the server in response to a request — delivering a complete, crawlable page to the browser. Here's how SSR works, how it compares to client-side rendering, and when it makes sense for your project.
- Domain name vs hosting: what's the difference?
An address versus a house — what a domain name is, what hosting is, and why you need both for a website.