What Is Cache? Browser, DNS, CDN, and Application Caching Explained
Learn what cache means, why computers and networks cache data, how browser, DNS, CDN, application, database, and CPU caches work, and when to clear a cache.
Answer snapshot
A cache is temporary storage for data that is likely to be reused. Instead of recomputing, redownloading, or re-querying the same thing every time, a system keeps a nearby copy and serves it faster. Browsers cache images and scripts, DNS resolvers cache hostname answers, CDNs cache web assets near users, applications cache API responses or sessions, databases cache query results, and CPUs cache memory. Caching improves speed and lowers load, but stale cache entries can make old data appear after the source has changed.
What you'll learn
- Understand what cache means across computers, browsers, DNS, CDNs, and applications
- Learn why caching improves speed, scale, and reliability
- Compare browser cache, DNS cache, CDN cache, application cache, database cache, and CPU cache
- Understand expiration, invalidation, eviction, and TTL
- Know when clearing cache helps and when it does not
A cache is temporary storage for data that is likely to be used again. Instead of fetching the same file, resolving the same hostname, calculating the same result, or reading the same database rows repeatedly, a system stores a nearby copy and reuses it.
Caching is one of the main reasons websites, applications, networks, and computers feel fast. It reduces latency, lowers traffic, and protects backend systems from unnecessary repeated work.
The tradeoff is freshness. If the original data changes while a cached copy still exists, users may see old data until the cache expires, is invalidated, or is cleared.
Simple Cache Example
Imagine a browser loading a logo from a website:
- The browser downloads
logo.png. - The browser stores a copy in its cache.
- The next page uses the same logo.
- The browser reuses the local copy instead of downloading it again.
The second page loads faster, the network transfers less data, and the web server does less work.
The same idea appears throughout computing: keep a useful copy close to where it is needed, then reuse it until it is too old, too large, or no longer valid.
Why Caching Exists
Caching exists because repeated work is expensive.
| Benefit | What it means | Example |
|---|---|---|
| Lower latency | Data is closer to the user or program | Browser reuses a local image |
| Less bandwidth | Fewer repeated downloads or queries | CDN serves an asset from a nearby edge |
| Lower backend load | Origin systems answer fewer repeated requests | API cache serves common responses |
| Better scale | One result can serve many users | DNS resolver caches an A record |
| More resilience | Some cached data remains usable during temporary origin problems | Static asset served from CDN cache |
Caching is not only a performance trick. It is a scaling strategy.
Common Types of Cache
| Cache type | What it stores | Where it usually lives |
|---|---|---|
| Browser cache | Images, CSS, JavaScript, fonts, HTML, connection metadata | User browser |
| DNS cache | Hostname lookup answers such as A, AAAA, CNAME, MX, TXT, and NXDOMAIN responses | Browser, OS, router, recursive resolver |
| CDN cache | Static files, images, scripts, video segments, sometimes generated pages | CDN edge locations |
| Application cache | API responses, rendered pages, user sessions, feature flags, computed results | App server, memory store, distributed cache |
| Database cache | Query results, indexes, hot rows, pages read from disk | Database engine or cache layer |
| CPU cache | Recently used memory values and instructions | Processor hardware |
These caches work at different layers, but the core idea is the same: reuse a nearby copy to avoid slower repeated work.
Browser Cache
A browser cache stores website resources on your device. Common cached files include:
- Images
- CSS stylesheets
- JavaScript bundles
- Fonts
- Favicons
- Some HTML documents
When you revisit a site, the browser can load cached files from disk or memory instead of downloading them again. This makes repeat visits much faster.
Browser cache can also cause confusion. If a site deploys a new file but your browser still has an old copy, the page may look broken or outdated until the browser revalidates the asset or you clear the cache.
Browser cache is different from DNS cache. A browser may cache both website files and DNS lookup answers, but those are separate concepts.
DNS Cache
A DNS cache stores answers from DNS lookups. For example, when a resolver learns that www.example.com points to 192.0.2.10, it can reuse that answer until the record's TTL expires.
DNS caching happens in several places:
- Browser DNS cache
- Operating system resolver cache
- Router or local forwarder cache
- ISP, corporate, or public recursive resolver cache
DNS cache is why DNS changes can look delayed. Your authoritative DNS provider may already serve the new answer, while recursive resolvers still return the old cached answer. That delay is usually what people call DNS propagation.
For the DNS-specific details, read DNS Cache Explained.
CDN Cache
A CDN, or content delivery network, caches content at edge locations near users. Instead of every visitor fetching files from one origin server, a CDN can serve cached copies from many locations.
CDN caches commonly store:
- Images
- CSS and JavaScript bundles
- Download files
- Video chunks
- API responses that are safe to cache
- Pre-rendered pages
CDN caching improves global performance, but it needs careful invalidation. If a file changes at the origin and the CDN keeps the old copy, users may keep receiving stale content until the cache expires or is purged.
Application and API Cache
Applications often cache expensive results:
- API responses
- Rendered page fragments
- User permissions
- Session data
- Product catalog data
- Feature flag evaluations
- Results from slow third-party services
Application caches are powerful because they can remove repeated work from a database or service dependency. They also need clear ownership rules. If the source data changes, the application must know whether to expire the cache, update it, or accept a short stale window.
Common application cache tools include Redis, Memcached, in-process memory caches, HTTP reverse proxies, and framework-level cache stores.
Database Cache
Databases cache heavily because disk and remote storage are slower than memory.
A database may cache:
- Frequently read disk pages
- Index pages
- Query execution plans
- Hot rows
- Result sets
Most of this is automatic. Operators usually tune memory, indexes, and query patterns rather than manually clearing database cache. Clearing a database cache in production can make performance worse because the database has to repopulate memory from slower storage.
CPU Cache
CPU cache is hardware-level memory built into or near the processor. It stores recently used data and instructions so the CPU does not have to wait for slower main memory every time.
CPU cache is not something most website owners clear manually. It matters for low-level performance, operating systems, compilers, and high-performance applications. It is included here because "cache" is a broad computing concept, not only a web concept.
How Cache Expiry Works
Cached data needs a freshness rule. Common patterns include:
| Mechanism | Meaning | Example |
|---|---|---|
| TTL | Keep the cached copy for a fixed number of seconds | DNS record cached for 3600 seconds |
| Revalidation | Ask the source whether the cached copy is still valid | Browser uses ETag or Last-Modified |
| Invalidation | Explicitly remove or replace the cached copy | Purge a CDN URL after deployment |
| Eviction | Remove cached data to free space | Least recently used item removed from memory |
| Versioning | Change the cache key when content changes | app.9f3a1.js instead of app.js |
DNS relies heavily on TTL. Web assets often use HTTP cache headers, ETags, and versioned filenames. Applications often combine TTLs with event-based invalidation.
What Clear Cache Means
To clear cache means to delete temporary cached data so fresh data is fetched or computed again.
Clearing cache can help when:
- A website shows old images, scripts, or styles.
- A DNS change is correct at the authoritative server but your device still sees the old answer.
- An application shows stale state after a deployment.
- A corrupted local cache causes broken behavior.
- You are testing a recent change and need to bypass old data.
Clearing cache does not fix every problem. If the source data is wrong, clearing the cache only fetches the wrong data again. In DNS troubleshooting, always compare the authoritative answer with resolver-cached answers before making more changes.
For DNS-specific commands, see How to Flush Your DNS Cache.
Cache vs Cookies vs Local Storage
These terms are often confused.
| Term | Purpose | Typical contents |
|---|---|---|
| Cache | Speeds up repeated access to reusable data | Files, DNS answers, API results |
| Cookies | Store small site data sent with requests | Session IDs, preferences, tracking IDs |
| Local storage | Stores browser-side application data | UI state, offline data, tokens in some apps |
Clearing browser cache may not clear cookies. Clearing cookies may sign you out but leave cached files intact. Clearing DNS cache is separate again.
Cache Problems
Caching creates predictable failure modes.
| Problem | What happens | Example |
|---|---|---|
| Stale cache | Old data is served after the source changed | DNS record changed but resolver still returns old IP |
| Inconsistent caches | Different users see different answers | One public resolver refreshed, another has not |
| Over-caching | Data is cached longer than it should be | Dynamic API response cached as static |
| Under-caching | Data is not cached enough | High query volume or slow repeat page loads |
| Cache stampede | Many requests refresh the same expired item at once | Popular API key expires and all workers recompute |
| Poisoned cache | False data enters a cache | DNS cache poisoning |
Good cache design is about choosing what can be cached, how long it can be cached, and how it should be refreshed.
DNS Cache Troubleshooting Example
Suppose you changed app.example.com from 192.0.2.10 to 198.51.100.25, but your laptop still reaches the old server.
Check the source of truth:
dig app.example.com A @ns1.dnscale.eu +shortThen compare public resolver caches:
dig app.example.com A @1.1.1.1 +short
dig app.example.com A @8.8.8.8 +short
dig app.example.com A @9.9.9.9 +shortIf the authoritative server returns the new IP and public resolvers return the old IP, you are waiting for recursive resolver cache expiry. Check the remaining TTL to estimate the window:
dig app.example.com A @8.8.8.8If the authoritative server itself returns the old IP, the cache is not the problem. The DNS record still needs to be fixed in the authoritative zone.
For a full workflow, use DNS Troubleshooting.
When Not to Clear Cache
Avoid clearing cache as a reflex in production systems.
Do not clear cache when:
- You have not confirmed the source data is correct.
- The cache is large and expensive to rebuild.
- Clearing it could send a sudden burst of traffic to a database, origin server, or API.
- The problem affects everyone and looks like a source-side configuration issue.
- The cache is managed by another provider or resolver and you do not control it.
For planned DNS changes, the better strategy is usually to lower TTL before the change, wait for old caches to age out, make the change, verify authoritative answers, and then restore a normal TTL.
Key Takeaways
- A cache is temporary storage for data that is likely to be reused.
- Caching makes systems faster and more scalable, but stale cached data can outlive a source change.
- Browser cache, DNS cache, CDN cache, application cache, database cache, and CPU cache work at different layers.
- DNS cache expiry is controlled mainly by TTL.
- Clearing cache helps with local stale data, but it does not fix wrong source data or remote caches you do not control.
- For DNS changes, compare authoritative answers and recursive resolver answers before changing more records.
Related Guides
Frequently asked questions
- What is cache?
- A cache is temporary storage for data that a system expects to reuse. It keeps a copy closer to where the data is needed so future requests are faster and the original source does less work.
- What does clear cache mean?
- Clear cache means deleting stored temporary copies so the system has to fetch, calculate, or resolve fresh data. It can fix stale results, but it can also make the next load slower because the cache must be rebuilt.
- Is cache the same as storage?
- No. Storage is usually the durable source of truth, such as a database, disk, or authoritative DNS zone. Cache is a faster temporary copy. If the cache disappears, the system should be able to recreate it from the source.
- What is the difference between browser cache and DNS cache?
- Browser cache usually stores website files such as images, scripts, CSS, and sometimes HTML. DNS cache stores name lookup answers, such as which IP address belongs to a hostname. Clearing browser assets does not always clear DNS answers.
- Why does cache become stale?
- A cache becomes stale when the source has changed but the cached copy has not expired or been invalidated yet. This is common with DNS changes, CDN assets, application responses, and browser files.
- Should I clear cache often?
- Usually no. Caches exist to improve performance. Clear cache when you are troubleshooting stale data, testing a recent change, fixing a corrupted local state, or following a support workflow. Routine clearing usually makes systems slower.
Related guides
Records
DNS A Record Explained — What It Is and How to Use It
Learn what a DNS A record is, how it maps domain names to IPv4 addresses, and how to create, query, and troubleshoot A records with practical dig command examples.
Records
DNS AAAA Record Explained — IPv6 Address Mapping
Learn what a DNS AAAA record is, how it maps domain names to IPv6 addresses, and how to set up dual-stack DNS with practical dig command examples.
Records
DNS CNAME Record Explained — Aliases and Canonical Names
Learn how DNS CNAME records create domain aliases, when to use them over A records, and how to avoid common pitfalls like apex restrictions and CNAME chains.
Records
DNS MX Record Explained — Mail Exchange Configuration
Learn how DNS MX records route email to mail servers, configure priority-based failover, and set up MX records for Google Workspace, Microsoft 365, and self-hosted mail.
Ready to manage your DNS with confidence?
DNScale provides anycast DNS hosting with a global network, real-time analytics, and an easy-to-use API.
Start free