ServerField Server operations and website growth
Updated July 2026 Web and HTTP terminology With configuration examples

What is a cache?
How it works, types, and clearing explained clearly

A cache stores past responses or computation results so they can be reused under the same conditions. We explain browser, CDN, and server caches; HIT, MISS, and 304; Cache-Control, ETag, and Vary; and clearing caches and applying updates, covering both design and troubleshooting.

Published: December 5, 2024 Last updated: July 29, 2026 Written and reviewed by the Finite Field Editorial Team
Browser cacheReuse without a request if fresh
HIT
CDN and shared cachesRevalidate conditionally if stale
304
Origin serverReturn the body if not stored or changed
MISS

cache key match + fresh → reuse
stale + validator match → 304 + reuse

This article contains no advertising or affiliate links. As of July 29, 2026, we checked HTTP caching against RFC 9111 and RFC 9110, additional directives and observation headers against relevant RFCs, and implementation details against official Mozilla MDN, Chrome, Cloudflare, and Google documentation.

Caching is more than temporarily storing data: it is a way to control which stored result may be reused, when, for whom, and under what conditions. Used well, it can speed up page loads and reduce server load and data transfer. Incorrect keys or update procedures, however, can result in stale information or responses intended for another user being served.

The answer in 30 seconds

A cache is defined by reuse conditions, not just stored copies

A web cache stores responses to requests and reuses them directly when the cache key matches and the response is fresh. Even after it becomes stale, an ETag or other validator can confirm that it has not changed, allowing reuse after a 304 response without retransmitting the body.

SpeedReduce network transfers, application processing, and database queries
CorrectnessControl freshness, user and language differences, and update propagation
OperationsPrepare versioned URLs, revalidation, purging, monitoring, and rollback
Summary of the definition, purpose, and cautions
In one sentenceA way to store past responses or calculations and reuse them later under the same conditions
Main benefitsReduce page load time, origin load, data transfer, and processing costs
Basic decisionMatching cache key → HIT if fresh, revalidate if stale, MISS if not stored
Important headersCache-Control、ETag、Last-Modified、Vary、Age、Cache-Status
Greatest risksShowing stale data for too long or mistakenly serving personalized responses from a shared cache
Safe updatesUse versioned URLs for static files, short freshness or revalidation for HTML and APIs, and targeted purges in emergencies

A cache stores results for reuse in later operations

In computing, a cache speeds up later operations by keeping data that takes time to fetch or calculate closer to where it is needed or in faster storage. Examples include CPU, DNS, browser, CDN, and database query caches.

This article focuses on web caching. In HTTP caching as defined by RFC 9111, a response to a request is stored and reused to answer subsequent requests. More important than the stored data itself are these four points:

1

Key

Identify which requests can use the same response based on URL, method, query, language, compression, and other factors.

2

Freshness

Set how long a stored response may be reused without validation, using max-age or s-maxage for shared caches.

3

Revalidation

Use an ETag or Last-Modified to check with the origin whether a stale response is still current.

4

Invalidation

Provide ways to stop using old versions, such as changing URLs on update, shortening lifetimes, or purging specific URLs or tags.

Cache

Derived data that can be recreated after deletion

Copies of images and HTML, API responses, and computation results that can be fetched or calculated again from authoritative data.

Authoritative data

Source data whose loss affects the business

Persist orders, member data, article drafts, billing records, and similar data in a database or file storage.

A cache is not a backup. If clearing a cache would destroy the only copy of an order or article, the responsibilities of authoritative data and acceleration data are mixed. Design caches so their contents can be correctly recreated if lost.

How requests result in HIT, MISS, or 304

A cache does not unconditionally return a stored copy based only on the URL. It selects candidates using the target URI, HTTP method, request headers specified by Vary, authentication and cookies, and product-specific key rules, then evaluates freshness and revalidation conditions.

1

Receive a request

For example, a browser requests GET /assets/app.v8.css .

2

Find a matching stored response

Select a candidate matching the URI, method, Vary headers, and other requirements. If none is available, it is a MISS.

3

Reuse a fresh response as a HIT

If its current age is less than its freshness lifetime and other requirements are met, a stored response can be used without contacting the origin.

4

Conditionally revalidate a stale response

If-None-Match carries the ETag; if unchanged, receive 304; if changed, receive 200 and the new body.

5

Store the new response and conditions

If the response is cacheable, store the body along with Cache-Control, ETag, Vary, and related information for later requests.

fresh HIT

Reuse without validation

current_age < freshness_lifetime means the stored response can be reused directly. An intermediate cache reports the age in Age.

304 revalidation

A request is made, but the body is not sent

A 304 is not a completely offline response. A conditional request and validation round trip still occur; only the body transfer is avoided.

What cache states mean
StateMeaningTypical behavior
HITA reusable stored response was foundReturn it from the browser or an intermediate cache
MISSNo matching response exists or it cannot be usedFetch from upstream or the origin
STALEThe freshness lifetime has expiredNormally revalidate; configuration may permit limited use of stale responses
304The stored representation is unchangedReuse the stored body without retransmitting it
BYPASSThe response is excluded from caching or reuse despite passing through a cacheForward to the origin due to authentication, cookies, rules, explicit settings, or similar conditions
HIT and MISS labels differ between products. A CDN may use proprietary headers such as CF-Cache-Status、X-Cache. Even when the standard Cache-Status is present, check the implementation documentation for value meanings and when it is emitted.

Benefits of caching and the risks of poor design

Caching does more than improve speed. It can reduce origin requests, data transfer, database queries, and dynamic generation, affecting reliability and operating costs. The same settings, however, create both benefits and risks.

Benefits

Four effects of reuse

  • Reduce latency by serving content closer to users
  • Reduce application processing and database queries
  • Reduce repeated transfers of the same body
  • stale-if-error can be designed to provide limited fallback responses during outages
Risks

Four failures to prevent before optimizing speed

  • Prices, inventory, or articles remain stale after an update
  • Sharing personalized pages leaks information
  • Different languages or encodings are served under the same key
  • A full purge causes a surge of misses and overloads the origin
A high HIT rate does not guarantee correctness. Quickly serving stale prices or another user's information is still a caching failure. Consider HIT rate alongside update delay, leak prevention, origin load, latency, and error rate.

Classify web caches by location and scope

Even one page may pass through multiple caches in the browser, CDN, reverse proxy, CMS, application, and around the database. Saying only that you cleared the cache is insufficient: identify the layer you changed.

Types and roles of web caches
TypeLocation and scopeSuitable contentMain considerations
Browser HTTP cacheInside a user's browser, normally for that device and profileImages, CSS, JavaScript, and revalidatable HTMLRetention differs by user; a hard reload does not clear the CDN
CDN and shared cachesDelivery points and proxies in front of multiple usersPublic images, versioned static files, and shareable HTML and APIsWatch for personalized responses, incomplete keys, edge differences, and purge scope
Reverse proxyNginx, Varnish, and similar services in front of the originExpensive-to-generate public HTML and APIsDecide how authentication cookies, language, device differences, and queries enter the key
CMS and page cacheWordPress or another CMS stores generated HTMLOperations that return the same public page for the same inputConnect drafts, scheduled publication, permission-based views, and update events to invalidation
Application and object cacheApplication memory, Redis, and similar storesConfiguration, aggregates, API results, and database query resultsManage invalidation when dependencies change, concurrent generation, and memory limits
Cache StorageManaged in the browser by JavaScript or a service workerOffline support, application shells, and custom fetch strategiesSeparate from the HTTP cache; update and delete in code rather than relying on automatic updates or expiration
Private

Private cache

A cache for one user, such as a browser cache. It can handle more response types than a shared cache, but sensitive information still requires careful controls.

Shared

Shared cache

A CDN or shared proxy reuses responses across users. Limit it to public responses and separate user-specific variations through keys or by prohibiting storage.

Separate

bfcache and service workers

The back-forward cache (bfcache) and Cache Storage are distinct from the HTTP cache. Keep them separate when investigating.

Key headers for controlling and observing HTTP caching

HTTP uses several headers to express whether a response can be stored, its sharing scope and freshness, revalidation, representation differences, current age, and how caches handled it. First decide whether the response is public, varies by user, can use a changed URL, and how many minutes of staleness are acceptable; then choose values.

HTTP cache-related headers
HeaderRoleWhat to check
Cache-ControlDirects storage, freshness, sharing, stale use, and moreChoose values by response type
ETagA validator identifying a representation versionIf-None-Match can yield 304 if it matches
Last-ModifiedLast modification time of the representationIf-Modified-Since enables conditional retrieval
VarySpecifies request headers that change the response for the same URLAccept-Encoding, Accept-Language, and others; too many variations can reduce hits
AgeApproximate seconds elapsed since the response was generatedCheck response age at a shared cache; it is not simply a timer since receipt
Cache-StatusA standard header describing how caches handled the requestIncludes hit, fwd, ttl, and similar fields; not all products always emit it
ExpiresA legacy mechanism specifying expiration as an absolute timeCache-Control max-age normally takes precedence when present

Common Cache-Control directives

Meaning of Cache-Control directives
ValueMeaningTypical use
max-age=secondsSeconds a response can be considered fresh after generationFreshness for caches including browsers
s-maxage=secondsSpecifies freshness for shared cachesUse different TTLs for browsers and CDNs
publicExplicitly permits storage by shared cachesPublic static files and shareable public responses
privateProhibits storage in shared caches and limits it to private cachesUser-specific pages and personalized responses
no-cachePermits storage but requires validation before reuseUpdated HTML and responses whose freshness must always be checked
no-storeRequests that the response not be storedHighly sensitive responses that should not remain in any cache
must-revalidateOnce stale, do not reuse without successful validationResponses where stale data could cause inconsistencies
immutableIndicates that the content will not change while freshStatic files with content hashes or versions in their URLs
stale-while-revalidate=secondsAllows a stale response to be served while revalidating for the specified timePublic content that tolerates some delay and benefits from reduced response waits
stale-if-error=secondsAllows a stale response to be used for the specified time during an upstream errorProviding public information for a limited period during an outage
Common misconception

no-cache does not prohibit storage

It requires validation with the origin before reusing a stored response. With an ETag, a 304 can avoid transferring the body when unchanged.

Stronger restriction

no-store prevents storage

It asks caches not to store the new response. Adding no-store later, however, does not command caches to delete all older responses stored for the same URL.

Observability points as of 2026: RFC 9211's Cache-Status can describe how multiple caches handled a response in a standard format. RFC 9213 also defines a framework for targeted Cache-Control fields such as CDN-Cache-Control. Check the CDN or proxy's official documentation for actual support and precedence.

Cache-Control examples by use case

These examples are starting points. Instead of applying the same values everywhere, adjust them based on whether the URL can change, how long stale content is acceptable, whether personal data is included, and whether browsers or CDNs should reuse the response.

1. CSS, JavaScript, and images with content hashes

Suitable for long-term storage

app.8d7c31.css are static files whose URLs change with their content and can be stored long-term provided old URLs are never overwritten.

HTTP response
Cache-Control: public, max-age=31536000, immutable
Once HTML references a new URL, the new file can be fetched while the old one remains cached. Do not combine a long TTL with overwriting content at the same URL.

2. HTML that changes

Suitable for revalidation

For articles or home pages that change at a fixed URL, allowing storage but validating before reuse is a straightforward approach.

HTTP response
Cache-Control: no-cache
ETag: "page-v42"

The client can send If-None-Match: "page-v42" and, if the content is unchanged, the server can return 304. This reduces transfer compared with sending the body each time.

3. Shareable public APIs

Use a CDN

For APIs that return the same public result for the same input and can tolerate a few minutes of update delay, browser and shared-cache freshness can differ.

HTTP response
Cache-Control: public, max-age=30, s-maxage=300,
               stale-while-revalidate=60, stale-if-error=600
Vary: Accept-Encoding
Do not casually apply this to APIs involving authentication, user-specific prices, definitive inventory, or permission differences. First identify variations caused by queries, headers, and cookies.

4. Sensitive user-specific pages

Avoid storage

Avoid storage for responses that should not remain in any cache, such as immediately after payment, medical or financial data, or one-time information.

HTTP response
Cache-Control: private, no-store

Do not mechanically add no-store to every logged-in page. Assess sensitivity, the back-navigation experience, and whether revalidation is sufficient for each case.

What happens when a cache is cleared? Methods by layer and safe updates

After a cache is cleared, the next request cannot use the stored result and must refetch, recalculate, or regenerate it. With an appropriate design, original orders, member records, articles, and source images are not deleted. However, selecting cookies or site data in the browser's clearing dialog may affect login state or locally stored information.

Clearing methods and effects by cache layer
LayerMain clearing and update methodsWhat happens next
Browser HTTP cacheBrowser settings, DevTools Clear browser cache, or a hard reloadFiles are fetched again, so the first load takes more data and time
CDNPurge by URL, prefix, tag, host, or all entries through an API or consoleThe next request is a MISS, increasing origin load
CMS page cacheArticle update event, plugin function, or targeted URL invalidationHTML is regenerated on the next request
Redis and application cachesDelete specific keys, use tags or generation numbers, TTLs, or event integrationDatabase queries or computations run again
Cache StorageService worker update logic, CacheStorage API, or DevToolsRefetch and store according to the fetch strategy defined in code

Five ways to apply updates quickly and safely

1

Include a version in static-file URLs

app.css should not be overwritten; use app.8d7c31.css when content changes.

2

Choose HTML and API TTLs based on acceptable propagation time

Do not assume 24 hours just because content updates daily; work backward from how many minutes the old version may remain after publication.

3

Enable revalidation with an ETag or similar validator

Return 304 if unchanged or a new 200 response if changed, balancing transfer volume and freshness.

4

Prefer purging specific URLs or tags

Keep full purges as a last resort; invalidate only updated pages and dependent assets.

5

Prepare for concentrated misses

When a full purge or simultaneous expirations are possible, prepare warmup, request coalescing, origin capacity, and rollback.

A full purge can create load while trying to remove a problem. If stored responses disappear at once, many misses reach the origin simultaneously. Except in emergencies, prefer targeted URL or tag purges, versioned URLs, and staged invalidation.

How to check whether caching works

For stale displays, misses, or differences after login, first identify the layer and record actual response headers. Do not judge from browser appearance alone; check the same URL multiple times under different conditions.

Check with Chrome DevTools

  1. Open Network in DevTools and load the target page.
  2. Select the request and check Headers for Cache-Control, Age, ETag, Vary, Cache-Status, and product-specific headers.
  3. Size and transfer information may show memory cache or disk cache, and Status may show 304.
  4. To simulate a first-time user, enable Disable cache. This primarily removes the browser cache's effect; it does not purge the CDN.
  5. Vary login state, language, query, cookies, and device conditions to check whether different responses are being mixed under one key.

Record response headers with curl

Terminal
# Fetch response headers only
curl -I https://example.com/assets/app.v8.css

# Request revalidation and compare the result
curl -I -H 'Cache-Control: no-cache' https://example.com/

# Send a conditional request using an ETag
curl -I -H 'If-None-Match: "page-v42"' https://example.com/

Request-side Cache-Control: no-cache does not command deletion of stored responses. It requests revalidation by caches along the path, and behavior varies with CDN and browser implementation and configuration.

Headers to inspect when investigating caches
ItemWhat it revealsConsiderations
Cache-ControlStorage scope, freshness, revalidation, and stale useCheck whether the CDN overrides it with its own configuration
AgeResponse age in a shared cacheA missing value alone does not prove the response was not cached
ETag / 304Whether conditional revalidation worksCheck weak ETags, compression differences, and generation differences across servers
VaryWhich request headers distinguish representationsVary: * and high-cardinality values can make reuse difficult
Cache-StatusHit status, forwarding reason, remaining TTL, storage, and moreOutput is optional; some implementations hide details for security
Product-specific headersCDN- or proxy-specific HIT, MISS, and BYPASS reasonsUse the product documentation for names and meanings

Caching, SEO, and Core Web Vitals

Simply enabling caching does not guarantee a higher search ranking. Appropriate browser, CDN, and server caches can nevertheless reduce server response work and resource transfers, providing a foundation for a better experience.

Within 2.5 secondsLCP: display of the main content
200 ms or lessINP: responsiveness to interactions
0.1 or lessCLS: visual stability
An example of improvement

Cache versioned static assets long-term

Reduce CSS, JavaScript, and image transfers on repeat visits and serve from the origin or a nearby CDN edge. Cache expensive public HTML within the scope that can safely be shared.

SEO consideration

Do not retain stale HTML for too long

Even after updating titles, content, prices, structured data, and canonical tags, stale HTML serves old information to users and crawlers. Design HTML revalidation or short TTLs and purges.

Google recommends good Core Web Vitals, but good numbers alone do not guarantee a high ranking. Improve caching alongside useful content, mobile presentation, image optimization, JavaScript volume, server processing, and internal links.

Common cache design mistakes and a pre-launch checklist

1

no-cache is mistakenly assumed to prohibit storage

no-store prohibits storage; no-cache requires validation before reuse.

2

Overwriting content at a long-TTL URL

Change the URL when the content of a long-cached static file changes.

3

Storing personalized responses in a shared cache

Do not assume authentication cookies make it safe; explicitly design private, no-store, bypass, and cache keys.

4

Omitting language, compression, or device differences from the key

List conditions that change the response and include necessary Vary headers or CDN keys.

5

Clearing only the browser and concluding the issue persists

Check the CDN, CMS, reverse proxy, Redis, and service worker separately.

6

Using HIT rate as the only success metric

Also observe update propagation, correctness, errors, leaks, origin load, and response time.

Ten pre-launch checks

  • Classify responses as public, user-specific, or sensitive
  • List conditions that change a response at the same URL
  • Add content hashes or versions to static assets
  • Decide acceptable staleness for HTML and APIs
  • Enable revalidation using ETag or Last-Modified
  • Keep personalized responses out of shared caches
  • Connect update events to purge and invalidation
  • Test login state, language, queries, and device differences
  • Plan for origin load after a full purge
  • Have bypass and rollback procedures for incidents

Frequently asked questions about caching

Simply put, what is a cache?

It stores previously fetched or computed results for reuse in later operations under the same conditions. On the web, browsers and CDNs store HTTP responses to reduce transfers and server work.

Does clearing a cache delete the original data?

Not with an appropriate design. Cached data is derived and can be fetched or regenerated from authoritative data in a database or files. Clearing cookies or site data at the same time, however, can affect login state and other local information.

Does Cache-Control: no-cache prohibit storage?

No. no-cache requires a stored response to be validated before reuse. The directive that prohibits storage is no-store.

Does 304 Not Modified mean no network request was made?

No. A conditional request and validation still take place. The server determined that the content was unchanged, so the stored body is reused without retransmission.

Does a hard reload also clear the CDN cache?

Usually not. A hard reload primarily changes how the browser fetches resources. To remove a stored CDN response, purge it through the CDN console or API.

Should a page updated daily use max-age=86400?

A response cached just before an update may remain available long afterward. Choose TTL based on acceptable staleness, revalidation, versioned URLs, and purging, not just update frequency.

Will content never be cached without Cache-Control?

Not necessarily. Without explicit freshness information, a cache may infer freshness from the last modification time or other information. Set an explicit policy for each response type to communicate your intent.

Is a higher cache HIT rate always better?

HIT rate alone is insufficient. Serving stale prices or another user's response at a high HIT rate is still a failure. Assess correctness, leak prevention, update delay, origin load, and response time together.

Standards and official sources reviewed

We prioritized standards for HTTP cache semantics and control, and checked browser, CDN, and search implementation and verification against official documentation. CDNs, CMSs, and reverse proxies can have their own rules, so also consult your product documentation in production.

Fact-checked July 29, 2026. Where standards and implementation documentation differ, we distinguish specification semantics from product-specific behavior.

Define reuse conditions and updates before choosing a cache location

A cache stores past responses or computations for reuse when later operations meet the conditions. Browsers, CDNs, reverse proxies, CMSs, and applications differ in sharing scope, keys, clearing methods, and observability.

Store static files long-term using versioned URLs, design freshness and revalidation for changing HTML and APIs, and do not share personalized responses. Targeted purges, preparation for concentrated misses, testing login and language variants and immediately after publication, and rollback procedures help balance speed and correctness.

Finite Field Editorial Team We edit practical information on web and application development, cloud architecture, UI design, and SEO improvements against standards and official documentation.

Website production by Finite Field

Go beyond cache settings to a site built for speed, SEO, and reliable updates.

Speed requires a coordinated design across the server, HTML structure, images, CSS and JavaScript, CDN, caching, and update workflow. Finite Field supports research, design, implementation, and post-launch operations for existing-site improvements and new websites.

SEO planning Core Web Vitals Responsive design Easy-to-update architecture
  • Review the current site's SEO, page speed, and cache settings
  • Improve information architecture and design for readability
  • Plan post-launch updates, measurement, and incident rollback
Discuss website production or improvements

We support both targeted improvements and complete redesigns.

Tell us what you can about the current URL, your challenges, update process, and desired timing.

After reviewing your request, we will explain whether and how we can help. We do not guarantee specific search rankings, speed, or revenue in advance.