Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

A cache keeps a reusable copy of data so a request can avoid repeating work or traveling to a slower system. But a browser, CDN, application and database-adjacent cache are separate copies with separate freshness rules. Clearing one does not clear the others, and changing the database does not automatically update every copy above it.

How does caching work across the stack?

Each cache sits between a caller and a source of data. When a requested item is present and reusable, the cache returns its copy; otherwise, it fetches or computes the item and may store it for later. A cache closer to the caller can avoid more network or processing work, but every additional layer adds another copy that can become stale.

Typical layers include a browser’s private HTTP cache, a shared CDN or intermediary cache, an application’s in-process memory, and an external cache between the application and database. These layers do not share a single clock or a universal “clear cache” switch. The HTTP rules for stored responses are specified in RFC 9111; MDN’s HTTP caching guide explains how those rules apply to browser and shared caches.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How does browser caching work?

For HTTP responses, the origin can communicate how a response may be stored and reused through headers. The key distinction is between freshness, validation and storage permission:

#1 Best Overall
Sale
Pearson Computer Networking, 8E
  • brand: Pearson
  • Computer Networking, 8e
  • Cache-Control: max-age=... sets a freshness lifetime. While a response is fresh, a cache can reuse it without asking the origin.
  • Cache-Control: no-cache does not mean “do not store.” It means a stored response must be validated before reuse.
  • Cache-Control: no-store tells caches not to store the response.
  • ETag and Last-Modified are validators. Once a response is stale, a cache can send a conditional request; if the representation has not changed, the origin can confirm the stored body is still usable rather than sending it again.

A cache also needs to know which requests can share a stored response. If the response depends on a request header, the server can name that header in Vary. Without the right variation in the cache key, a representation produced for one request context could be reused for another. This matters especially for personalized or authenticated responses: decide whether they can be stored at all, and whether any shared cache can reuse them. RFC 9111 describes the protocol rules for cache matching and shared versus private caches.

What does a CDN cache, and what does a purge do?

A CDN stores copies at edge locations so later requests can be served without reaching the origin. Origin Cache-Control directives can guide caching, but CDN products may also provide vendor-specific controls, cache modes or defaults. Check the configuration for the CDN in use rather than assuming the origin header is the only rule.

For example, Google Cloud CDN’s caching documentation describes private as preventing storage in its shared CDN cache, while no-store is for responses that should not be stored by any cache. Cloudflare’s CDN-Cache-Control documentation describes controls that can set different freshness policies for CDN and browser caches. These are examples of provider behavior, not guarantees that every CDN interprets or configures caching identically.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A purge or invalidation removes selected entries from the CDN before they would ordinarily expire, so a later request can refill from the origin. Its scope is limited: Google Cloud states that “Invalidations don’t affect cached copies in web browser caches or caches operated by third-party internet service providers.” A browser may therefore continue to use its own still-fresh copy after the CDN has been purged.

Invalidating too much can create a traffic surge as requests that had been served from cache reach the origin. Google Cloud advises: “Invalidate only what you must because invalidating too much might cause a spike in requests that the caches were serving to suddenly hit your instances or buckets.” Distributed invalidations can also take time to propagate. See Google Cloud’s cache invalidation overview for its scope and operational guidance.

Should you use an application cache, Redis or the database alone?

There is no workload-independent winner. A cache is most useful when repeatedly requested data is expensive to fetch or compute and its reuse outweighs the cost of storing, maintaining and refreshing the copy. An application can cache in its own process memory or use a separate service such as Redis between the application and database. Client-side caching can also keep copies in a client library, reducing repeated requests to the cache server; Redis notes that local memory access avoids a network service request.

  • Consider how frequently the data is read versus changed, how concentrated requests are on a small set of popular keys, and the latency or database load a hit could avoid.
  • Account for memory use, cache misses, cache-key correctness, invalidation fan-out and operational complexity.
  • Include privacy and authorization boundaries: a cached value must not cross users or access scopes.
  • Decide what should happen during an origin or database failure, including whether stale data may be served.

Common application patterns make different choices about when the cache is populated and updated. In cache-aside, the application checks the cache first, reads from the database on a miss, then puts the result in cache; a write typically updates the database and then deletes or refreshes the relevant cache entry. In write-through, a write updates the database and cache as part of the write path. In write-around, a write goes to the database without populating the cache, so a later read can fill it. These are design patterns, not guarantees of consistency: correctness still depends on failure handling, ordering and invalidating every relevant copy.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Redis documents server-assisted client-side caching, where the server tracks keys a client has read and can send invalidation messages when a tracked key changes. This can help clients discard local copies, but it adds tracking, connection and client-support requirements. Redis’s client-side caching documentation explains the mechanism and its limitations.

Expiration also affects load, not just freshness. An AWS whitepaper on database caching with Redis warns that many entries expiring together under heavy load can drive a wave of requests to the backend database. Staggering expirations or using other load controls may help, but the right mitigation depends on the workload. The AWS whitepaper discusses this expiration risk.

What is the difference between a cache TTL and invalidation?

A time-to-live (TTL) or freshness lifetime gives an entry a time-based limit: after it expires, a cache should no longer treat it as fresh. Invalidation is an event-based attempt to remove or mark a copy unusable when the underlying data changes. TTLs bound how long a copy can remain fresh under the cache’s rules; invalidation aims to react sooner, but only if the write reaches the right cache and affected keys.

Neither mechanism alone guarantees that every layer immediately reflects a write. A short TTL can reduce the time stale data remains reusable but may increase origin or database traffic. Invalidation can make updates visible sooner, but it requires a reliable path from each write to every relevant copy. Redis documentation puts the underlying requirement plainly: “All caching systems must implement a scheme to update the data in the cache when the corresponding data changes in the main database.” See Redis’s client-side caching introduction.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Why am I still seeing stale data after an update?

Stale data is not always evidence that a purge failed. A copy might still be fresh according to its own TTL, an invalidation may have missed that layer or key, or a cache key may not distinguish requests that need different representations. Multiple layers can also refresh at different times. Some caches deliberately serve stale content while revalidating or during an origin error, trading strict freshness for availability.

That trade should match the data’s risk. A public static asset can often use a long lifetime when deployments give changed files new, versioned URLs. Account balances, permissions and inventory are examples where stale or cross-user data can cause greater harm and therefore call for stricter freshness and privacy rules. These are design judgments, not universal TTL prescriptions.

Some CDNs support explicit stale-serving controls. Cloudflare documents stale-while-revalidate and stale-if-error behavior alongside its cache controls. Such options can keep a site responsive during revalidation or origin problems, but their semantics and configuration are provider-specific; see the Cloudflare documentation.

How do you trace and fix a stale response?

  1. Identify the exact response. Record the URL, request headers and user context, then check response headers such as Cache-Control, Age, ETag, Last-Modified and Vary where present. Confirm whether the response is personalized and which request dimensions should distinguish it.
  2. Check each hop independently. Compare what the browser receives with what the CDN and origin return, then inspect any application or database-adjacent cache. Determine which layer supplied the old representation; a CDN purge cannot remove a browser’s copy or an application’s local entry.
  3. Verify the freshness rule and cache key. Check the configured TTL and whether conditional validation is occurring after expiry. If a response changes by language, device, authorization or another header, confirm the cache key or Vary policy accounts for that dimension.
  4. Invalidate the affected copy. Purge only the necessary CDN object or path, and use the application’s own invalidation mechanism for application-level copies. Allow for propagation where the provider is distributed, and verify the result from the affected path rather than assuming one purge clears every cache.
  5. Correct the policy that caused recurrence. Adjust freshness, validation, storage permission or versioning as appropriate. Test that private responses cannot be reused across users, that updates invalidate the right keys, and that a broad expiration or purge will not overwhelm the origin.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.