Need email infrastructure? Try PostScale -- transactional email API built in the EU. PostScale

    FundamentalsBeginner

    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:

    1. The browser downloads logo.png.
    2. The browser stores a copy in its cache.
    3. The next page uses the same logo.
    4. 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.

    BenefitWhat it meansExample
    Lower latencyData is closer to the user or programBrowser reuses a local image
    Less bandwidthFewer repeated downloads or queriesCDN serves an asset from a nearby edge
    Lower backend loadOrigin systems answer fewer repeated requestsAPI cache serves common responses
    Better scaleOne result can serve many usersDNS resolver caches an A record
    More resilienceSome cached data remains usable during temporary origin problemsStatic asset served from CDN cache

    Caching is not only a performance trick. It is a scaling strategy.

    Common Types of Cache

    Cache typeWhat it storesWhere it usually lives
    Browser cacheImages, CSS, JavaScript, fonts, HTML, connection metadataUser browser
    DNS cacheHostname lookup answers such as A, AAAA, CNAME, MX, TXT, and NXDOMAIN responsesBrowser, OS, router, recursive resolver
    CDN cacheStatic files, images, scripts, video segments, sometimes generated pagesCDN edge locations
    Application cacheAPI responses, rendered pages, user sessions, feature flags, computed resultsApp server, memory store, distributed cache
    Database cacheQuery results, indexes, hot rows, pages read from diskDatabase engine or cache layer
    CPU cacheRecently used memory values and instructionsProcessor 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:

    MechanismMeaningExample
    TTLKeep the cached copy for a fixed number of secondsDNS record cached for 3600 seconds
    RevalidationAsk the source whether the cached copy is still validBrowser uses ETag or Last-Modified
    InvalidationExplicitly remove or replace the cached copyPurge a CDN URL after deployment
    EvictionRemove cached data to free spaceLeast recently used item removed from memory
    VersioningChange the cache key when content changesapp.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.

    TermPurposeTypical contents
    CacheSpeeds up repeated access to reusable dataFiles, DNS answers, API results
    CookiesStore small site data sent with requestsSession IDs, preferences, tracking IDs
    Local storageStores browser-side application dataUI 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.

    ProblemWhat happensExample
    Stale cacheOld data is served after the source changedDNS record changed but resolver still returns old IP
    Inconsistent cachesDifferent users see different answersOne public resolver refreshed, another has not
    Over-cachingData is cached longer than it should beDynamic API response cached as static
    Under-cachingData is not cached enoughHigh query volume or slow repeat page loads
    Cache stampedeMany requests refresh the same expired item at oncePopular API key expires and all workers recompute
    Poisoned cacheFalse data enters a cacheDNS 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 +short

    Then 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 +short

    If 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.8

    If 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.

    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

    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