Mirage CDN
Operations / field guide 08

How a cache is purged

Understand invalidation, expiry and versioned URLs, then plan a cache purge with clear scope, verification and recovery steps.

By Mirage CDN · Updated

Purging a cache means asking a managed cache system to stop reusing selected stored responses. The exact operation depends on the implementation: it might remove entries, mark them stale, or change which version a lookup can select. Before using a purge interface, establish its scope and completion semantics. An accepted request and a verified content change are different pieces of evidence.

This article presents an operational design and a test procedure. Mirage CDN includes purge by URL and prefix through its dashboard and API. Account-specific instructions are supplied during onboarding; no purge completion time is promised.

Separate expiry, validation and invalidation

Expiry is the end of freshness. Validation checks a stored representation against the origin. Invalidation prevents ordinary reuse until the cache has an appropriate response. RFC 9111 requires particular invalidation behavior when a cache receives a non-error response to an unsafe method, including status classes 2xx and 3xx; that rule is not a distributed purge API. RFC 9111, invalidation

A conditional request can validate an existing representation using metadata such as an entity tag or modification date. A 304 response can avoid retransmitting an unchanged body. That can be useful after a policy change, but it is not proof that a changed file reached every cache you operate. HTTP conditional requests

For a correction workflow, write the intended outcome in content terms: “the public document now contains revision B.” Then decide how the cache should get there. A command that reports success without checking the response body proves only that the control request was accepted at the layer you contacted.

Establish the exact scope

Build a small inventory before purging: scheme, host, path, meaningful query values, negotiated variants and any separate cache tiers. Ask the implementation documentation which of those dimensions the operation selects. A path-only request may not describe every variant you intended to replace.

For example, a public catalogue might have an HTML document, a downloadable PDF and small preview images. Correcting one entry might require changing all three. Treat the purge selection as part of the release manifest, so the reviewer can compare the changed files with the requested invalidations. Avoid a broad site purge when a precise set of public resources addresses the correction.

Also identify the cache layers outside the managed system. A command sent to a CDN does not reach a disconnected visitor’s browser. The Clear Site Data specification defines a separate response-header mechanism for clearing eligible browser storage. That mechanism depends on a user agent receiving and supporting the response; it is not an instantaneous recall of copies already delivered. Clear Site Data specification

Publish correct origin content first

Use a disposable fixture to rehearse the sequence. Prepare revision A and revision B with obvious body markers and recorded checksums. Confirm the origin serves B before requesting invalidation. If a cache fetches immediately after invalidation while the origin still serves A, the operation can refill the cache with the very representation you wanted to replace.

That sequence is a practical deployment inference, not a protocol guarantee. Write it into the runbook with the relevant origin identifier and release revision. Keep the previous release available until the correction is verified. A purge cannot repair a missing origin file, an incorrect routing rule or an application returning the wrong bytes.

For urgent removal, treat the origin fix and access policy as the primary controls. Do not regard cache invalidation as deletion of every copy someone may already have downloaded. Review the incident according to the data involved and keep the technical report specific about which systems were actually checked.

Plan for stale-serving policy

The extensions stale-while-revalidate and stale-if-error can authorize reuse of stale responses under defined circumstances. Their purpose is different from content removal. A purge design must say how invalidated entries interact with these policies and with in-progress origin fetches. RFC 5861

In a rehearsal, test a normal origin response and an origin error separately. Record whether revision A can still be selected after invalidation, whether a concurrent fetch can reintroduce it, and which result the user receives when B cannot be fetched. These are implementation acceptance questions; do not infer the answers from a status label.

Prefer new URLs for immutable assets

For assets designed never to change at one URL, publish a new filename and update the referring document. A versioned release manifest makes the transition reviewable: document B refers to asset B, while an already-open document A can still retrieve asset A. This avoids making a routine release depend entirely on invalidating an older asset.

Retain previous assets for the application’s supported transition period. Choose that period based on your update policy and long-lived documents, then test a rollback using the retained manifest. The immutable and max-age guide explains the response-policy side of this design.

Verify the result and preserve recovery

Record the purge request identifier, selection and observed completion state when the system provides them. Then issue ordinary requests through the intended delivery path and compare the body with revision B. Use a separate client session to check that your result was not merely a local browser refresh. Test the variants named in the release manifest.

If only one route or cache location was observed, report that scope. Do not turn a single successful request into a claim about unobserved nodes. Finish the runbook with a recovery decision: restore the previous document and its assets, correct the origin, or repeat a precisely scoped invalidation. Keep evidence of the action and evidence of the served content separate.

Sources

This guide explains technical concepts. For your delivery setup, review the documentation and request an account from our team.

Read the integration docs · Explore more CDN guides