CDN caches
A CDN in front of the site keeps copies of its pages so fewer visitors reach the server. Without more, a published change shows only when the CDN's copy expires. SHADE can clear (purge) a CDN's cache itself, at the right moment after each publish, so visitors see the change right after the build. Each cache SHADE clears is a purge target.
What users can do
Admins, under Settings → CDN caches (next to Other frontends):
- Add a cache: a name, what it is in front of, the service and its settings.
- Cloudflare: the zone ID and an API token. Fastly: the service ID and an API token. Netlify: the project ID and a personal access token. The token is stored encrypted, is never shown again, and only "Token saved." says it is there.
- Purge webhook: an https address of your own (a reverse proxy, a script). SHADE gives a signing secret, shown once: copy it then.
- Send test purge: clears a tag nothing carries, so it checks the token, the zone, service or project, or the address without clearing anything. The row then shows how it went.
- See when each cache was last cleared, or that it failed and why.
- Remove a cache: SHADE no longer clears it; its copies stay until they expire.
Editors and admins: Clear cache now clears every cache at once, beside Rebuild now on the website module's Builds screen, and on the CDN caches card. With no cache set, it clears nothing and says so: "No CDN caches are set", with a pointer to Settings → CDN caches.
When the admin is reached through a CDN and no cache is listed, the card warns: "No cache is cleared after a publish".
Who may do it
| Action | Permission | Roles |
|---|---|---|
| See, add, test and remove caches | settings.read, settings.update | admin |
| Clear cache now | rebuild.trigger | admin, editor |
| Report a frontend's build | a build token; nobody else | the frontend's builder |
Adding and removing a cache is audited as settings.update; Clear cache now as rebuild.trigger; a frontend's build
report as build.report.
When a cache is cleared
What a cache is in front of decides when SHADE clears it, and what:
| In front of | Cleared | What |
|---|---|---|
| This website | after the site's builder reports a build that worked | everything on the Site URL's host |
| Another frontend with a build hook | after its builder reports a build that worked | everything on its host |
| Another frontend without a build hook | when the rebuild starts | everything on its host |
| The API's public routes | when the rebuild starts | every module answer tagged shade-routes |
| Media files | when a file is deleted for good | that file's address |
- After the build, never before. Clearing before the new pages are built would let the CDN fetch the old pages again. A failed build clears nothing. A builder that doesn't report its builds gets no clear: the card says so.
- Whatever asks for a rebuild clears too: publishing, unpublishing, deleting, scheduled publishes, releases, site settings, modules switched on or off, the theme and redirects (What requests a rebuild).
- Gathered. Many publishes in a row give one clear per cache, at most one a minute. A clear asked for meanwhile joins the one that waits.
- Deleted files. A media file deleted for good (from the trash, or by retention) is cleared by its address on the media's cache, so an erased image doesn't stay on the CDN.
- Clear cache now clears everything on every cache, within the minute.
- Each service clears what it can. Fastly has no clear by host: "everything" is everything on the Fastly service, so a service with more domains is cleared whole. Netlify clears a whole project or tags, never one address: a deleted file clears the whole project behind it. Every clear is a full one, never Fastly's soft purge, which may still serve the old copy.
Rules and limits
- A failed clear never fails a publish or a build. SHADE tries again after 1, 2 and 4 minutes. The card shows the
failure in its own words, never the CDN's answer, and after the last try it goes to the error log as
purge: <name>. A service that keeps failing raises the "An outside service keeps failing" alert (Errors). - Every call goes out over https only, to public addresses only, waits 10 seconds at most and never follows a
redirect. Each CDN is always called at its own address:
api.cloudflare.com,api.fastly.com,api.netlify.com. - Cloudflare takes at most 30 addresses, tags or hosts per call: SHADE sends more in several calls. Fastly takes at most 256 tags per call and one address per call; past 25 addresses SHADE clears the whole service instead. A purge webhook gets at most 500 addresses per message.
- Netlify clears a project or a tag at most twice every 5 seconds. SHADE sends at most one clear a minute per cache, so this limit is only met when something else clears the same project too.
- The content API's answers are never cached by a CDN (
Cache-Control: private, no-store): it is build traffic behind a token. - A module's public route with a cache gets the tag
shade-routesinCache-Tag(Cloudflare, Netlify) andSurrogate-Key(Fastly, Varnish). A module's own tags are dropped.
With Cloudflare
- In Cloudflare, open the site's zone. On its Overview page, under API, copy the Zone ID.
- Under My Profile → API Tokens, create a token with the permission Zone → Cache Purge → Purge, and under Zone Resources only this zone. Give it nothing else.
- In SHADE, open Settings → CDN caches → Add a cache. Choose what the zone is in front of (usually This website), Cloudflare, paste the zone ID and the token, and save.
- Click Send test purge. "Cleared" means the token works on this zone. "The CDN refused the token" means it may not purge this zone.
- Publish a change. After the site's build, the row shows when it was cleared.
A site on Cloudflare Workers with static assets doesn't need this: each deploy serves its own files.
With Fastly
- In Fastly, open the service in front of the site. Copy its service ID, shown beside its name.
- Under Account → API tokens, create an automation or user token with only the scopes purge_select (Purge select content) and purge_all (Purge full cache), limited to this service. Give it nothing else.
- In SHADE, open Settings → CDN caches → Add a cache. Choose what the service is in front of, Fastly, paste the service ID and the token, and save.
- Click Send test purge. "Cleared" means the token works on this service. "The CDN refused the token" means it may not purge it, or it expired.
SHADE clears everything with purge_all, the API's tag with the surrogate key shade-routes and a deleted file by
its address, each sent with the token in the Fastly-Key header.
With Netlify
- In Netlify, open the project. Under Project configuration → General → Project details, copy the Project ID (called Site ID before).
- Under User settings → Applications → Personal access tokens, create a token, with an expiry date if you like. Netlify can't limit a token to one project: it reaches every project the account that made it can. Make it with an account that can reach only this project where your plan allows that.
- In SHADE, open Settings → CDN caches → Add a cache. Choose what the project is in front of, Netlify, paste the project ID and the token, and save.
- Click Send test purge. "Cleared" means the token works on this project. "The CDN refused the request" means the project ID is wrong.
A static site deployed on Netlify doesn't need this: each deploy is served fresh. A Netlify cache helps in front of the API's public routes or a frontend rendered on request, which Netlify caches only when their answers say so.
With a purge webhook
SHADE sends a POST with a JSON body to your address, signed as SHADE's outgoing webhooks are (Standard Webhooks:
webhook-id, webhook-timestamp and webhook-signature, with the secret shown when the cache was added):
{
"type": "cache.purge",
"timestamp": "2026-11-14T10:00:00.000Z",
"data": { "hosts": ["www.example.org"], "tags": [], "urls": [] }
}
hosts: clear everything on these hosts. tags: clear every answer carrying the tag (shade-routes). urls: clear
these addresses. Check the signature with any Standard Webhooks library, and answer with a 2xx status when it is done.
For developers
The code and its tests: shade/features/content-delivery/README.md in the shade repository, decision 0016 point 11.