Safeguard
Security Guides•

Do you need to purge the CDN cache after a security fix?

Often yes. A fix that is deployed but cached stays invisible to visitors. Steps to purge safely, verify the new files and handle old copies.

Safeguard Security Team
4 min read

Often yes. A fix you have deployed does not reach visitors while a cache still serves the old file. After a security change, purge the affected paths, confirm the new content is served from the edge, and check that old copies are not kept by browsers or other shared caches.

Why it matters

A CDN is a shared cache sitting between your origin and visitors. MDN describes a shared cache as one that stores a single response and reuses it for many users, and notes that the s-maxage directive sets how long a response stays fresh in shared caches. If you patched a vulnerable script and its cached copy lives for a day or a week, visitors keep getting the vulnerable file until it expires or you purge.

Browsers cache too. A response marked for a long max-age can sit on a visitor's device regardless of what the edge does.

Steps

  1. Identify what changed. List every URL whose content or headers changed: scripts, HTML pages, config files, redirect rules.
  2. Check how each is cached. Look at the Cache-Control header on those URLs. Note s-maxage, max-age and any immutable directive.
  3. Deploy the fix. Ship the change to the origin or the static host.
  4. Purge. Use your CDN's purge feature for the exact paths, or a version tag if it supports one. A full purge is a blunt tool and causes a burst of origin requests, so prefer targeted purges for a small change.
  5. Verify at the edge. Request the file with curl and read the response. Confirm the content changed, and check any cache status header your CDN sets.
  6. Verify from outside. Test from a different network or region if your CDN has many edge locations, since purges can take time to propagate.
  7. Handle browser copies. If the old file was cached with a long lifetime, a purge will not reach browsers. Change the file name, usually by including a content hash, so pages request a new URL.
  8. Record it. Note the time of deploy, time of purge and the verification result in the incident or change ticket.

Make the next fix easier

PracticeBenefit
Content-hashed file names for scripts and stylesA new version gets a new URL, no purge needed
Long cache for hashed files, short for HTMLFast pages and quick rollouts
Never cache private or personalised responses in shared cachesAvoids serving one person's data to another
Keep HTML short-lived or revalidatedPages pick up new file names promptly

MDN warns that personalised content should not be stored in shared caches, because one stored response is reused for many users. Use the private directive or no-store for anything tied to a person.

Do not forget what else holds copies

Search engine caches, web archives and third-party mirrors may keep old versions. For a leaked secret, rotating the secret matters far more than purging, because you cannot recall every copy.

Try it yourself

The fix-available demo shows a vulnerable package moving to a fixed version. Notice that the fix is not complete until the new version is what actually runs, which on a CDN site means what is actually served.

Click through it at your own pace, or open it full screen.

Where Safeguard fits

Safeguard can find the vulnerable dependency and raise a fix pull request when you enable that option. Purging and verification remain steps in your own release process. Free scan: gold.safeguard.sh/scan.

Quick check

Is a purge enough if a secret was exposed?

No. Rotate the secret. Copies may exist outside your cache.

Why use hashed file names?

Each release gets a new URL, so no cache can serve a stale version of it.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.