CDN Caching and Cache-Control Headers: A Practical Guide to Fresh Content
CDNcachingCache-Controlwebsite performanceHTTP headersdeployment

CDN Caching and Cache-Control Headers: A Practical Guide to Fresh Content

TTruly Cloud Editorial Team
2026-11-20
7 min read

Learn how to diagnose stale website content, read Cache-Control headers, purge the right cache layer, and keep CDN caching predictable.

If your website is showing old content after a deployment, the cause may be a browser cache, CDN edge cache, page cache, or incorrectly cached asset. This guide explains how to read the relevant HTTP headers, choose safe caching rules, purge the right layer, and establish a repeatable checklist for keeping HTML, CSS, JavaScript, images, and API responses fresh without disabling caching altogether.

Overview

Caching stores a response closer to the visitor so the server does not need to generate or transfer the same content for every request. A typical request can pass through several caching layers: the visitor’s browser, a CDN or reverse proxy, a page cache in the hosting stack, and an application or database cache. Each layer can have a different copy of the response and a different expiration time.

That is why clearing one cache does not always fix a stale page. Purging a CDN does not remove a file already stored in a browser. Removing a WordPress page cache does not necessarily clear an edge cache. Changing DNS may direct new requests to a different service, but it does not directly invalidate an old HTML response.

The main control is the Cache-Control response header. It tells browsers and shared caches how a response may be stored and when it should be checked again. Other useful signals include ETag, which identifies a particular version of a response, Last-Modified, which supplies a modification time, and Age, which can indicate how long a response has been held by a shared cache. CDN dashboards may also show provider-specific fields such as cache status, hit or miss, or cache key information.

What to track

Track caching by content type rather than applying one rule to the entire domain. The following starting points are intentionally general; confirm them against your application, CDN, and deployment process.

ContentTypical policy to evaluateWhat to monitor
HTML pagespublic, max-age=0, must-revalidate or a short shared-cache lifetime when the page can be safely cachedWhether deployments appear quickly and whether personalized pages are excluded
Versioned CSS and JavaScriptLong-lived public caching, often with a filename or URL that changes when the file changesWhether new HTML references the new asset version
Images and fontsLong-lived caching when files are replaced using versioned names or controlled purgesWhether replacements use a new URL or require invalidation
APIs and account pagesprivate or no-store where responses contain user-specific or sensitive dataAuthentication, cookies, authorization, and accidental shared caching

max-age describes how long a browser may use a response without checking again. s-maxage can provide a separate freshness period for shared caches such as CDNs. no-cache does not mean “do not store”; it generally means the stored response must be revalidated before reuse. Use no-store when a response should not be stored. private prevents shared caches from storing a response intended for one user.

For static assets, cache busting is usually clearer than repeatedly purging the entire site. A build system may produce names such as app.abc123.js. When the file changes, the name changes, and the new HTML points to the new resource. For a file whose URL cannot change, use a targeted purge or a shorter lifetime and test the replacement path carefully.

Use a response inspection tool to compare requests from different locations and layers. A command such as curl -I https://example.com/ can reveal response headers, while browser developer tools can show request timing, cache status, and whether the browser served the resource from memory or disk. CDN cache-status headers vary by provider, so treat fields such as X-Cache as diagnostic signals rather than universal standards.

Cadence and checkpoints

Check caching after every release that changes HTML, CSS, JavaScript, images, routing, or CDN configuration. A small monthly or quarterly review is also useful for sites with frequent deployments or multiple administrators.

  1. Record the intended policy. List the expected behavior for HTML, static assets, APIs, and error responses. Note which URLs are versioned and which require purge operations.
  2. Test the origin first. Request the content directly from the hosting or application origin where practical. Confirm that the origin itself serves the new version and sends the intended headers.
  3. Test the public hostname. Compare the public response with the origin response. Check Cache-Control, ETag, Last-Modified, Age, redirects, and any CDN cache-status field.
  4. Test from a clean browser session. Use a private window or a separate browser profile, then compare with a normal session. This distinguishes a local browser copy from a shared-cache problem.
  5. Inspect dependencies. Confirm that the new HTML references the expected CSS and JavaScript URLs, that service workers are not serving an older asset, and that a page or plugin cache has been cleared if one is present.
  6. Document the remedy. Record the affected URL pattern, layer, purge action, header change, and verification result. This turns the next incident into a short procedure instead of guesswork.

Purge narrowly when possible. Clearing only the changed page or asset reduces disruption and makes it easier to verify the result. If a CDN offers purge by URL, tag, host, or cache key, use the smallest scope that covers the deployment. Avoid relying on a purge as the primary release mechanism when versioned asset URLs can provide a more predictable workflow.

How to interpret changes

If the origin serves old content, the problem is not the CDN. Check the deployment, application cache, filesystem, or hosting layer first. If the origin is current but the public hostname is old, inspect the CDN policy, cache key, purge status, and whether another hostname or proxy is serving the request.

If only one browser sees the old version, focus on its cache, service worker, extensions, or local network behavior. A hard refresh can help diagnose the issue, but it is not a durable fix for visitors. If HTML is current but the page still looks old, inspect the CSS, JavaScript, image, and font requests individually. An unchanged asset URL with a long freshness lifetime is a common explanation.

A high Age value can indicate that a shared cache has served the object for some time, but its meaning depends on the response path and provider. An ETag or Last-Modified value changing does not force every layer to discard its existing object; the cache must revalidate or be purged according to its policy. Also check whether query strings, cookies, authorization headers, or hostnames create separate cache keys.

Be particularly careful with personalized pages, shopping carts, dashboards, login routes, and API responses. Caching these responses publicly can expose one user’s content to another. Where content is sensitive or user-specific, prefer an explicit private or no-store policy and verify behavior with an authenticated test account.

For WordPress and other managed applications, review page-cache settings alongside CDN settings. A useful related check is your comparison of managed WordPress and static hosting, while the website resource usage guide can help identify whether slow origin performance is being mistaken for a cache problem.

When to revisit

Revisit this guide after a major CDN, hosting, browser, framework, or deployment change, and at least quarterly for a site with active releases. Also review the policy after a theme or plugin update, a migration, a DNS or proxy change, a new service worker, or a recurring report that the website is showing old content.

Keep a small cache register with the URL pattern, content type, intended directives, asset-versioning method, purge scope, and last verification date. During each review, test one representative HTML page, one CSS or JavaScript asset, one image, and one API or authenticated route if applicable. Save the response headers and note whether the result came from the browser, CDN, origin, or application cache.

When an incident occurs, do not begin by disabling all caching. First identify the stale layer, confirm the origin version, purge the narrowest affected scope, and verify the public response from a clean session. Then fix the policy or deployment naming that allowed the problem. This approach preserves the performance benefits of CDN caching while making fresh content a controlled, testable part of website and DNS management.

Related Topics

#CDN#caching#Cache-Control#website performance#HTTP headers#deployment
T

Truly Cloud Editorial Team

Technical Editor

Senior editor and content strategist. Writing about technology, design, and the future of digital media. Follow along for deep dives into the industry's moving parts.