Purging
A purge removes one file, a folder, every file carrying a cache tag, or a whole zone from every location. It is queued by one call, applied within about fifteen seconds, and a second call reports how far it has got.
Purge a file, a folder, a tag or the zone#
POST https://api.cachegenie.com/v1/cdn/{ZONE_ID}/purge- PURGE_URL (String, optional): the full http or https URL of one file on one of the zone's hostnames, up to 2,048 characters, or of a folder: a URL whose path ends in
*, with no query string, purges every file under it (https://cdn.example.com/videos/*). - PURGE_TAG (String, optional): one cache tag your origin sent in
Cache-TagorSurrogate-Key, up to 128 characters, no spaces or commas, not case-sensitive. Every cached file that carried it is purged.
Send at most one of the two. Send neither, send them as null, send no body, or send a body that is not JSON, and the whole zone is purged.
curl -X POST https://api.cachegenie.com/v1/cdn/AB12CD34E/purge \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"PURGE_URL": "https://cdn.example.com/videos/intro.mp4"}'{
"CODE": 200,
"MESSAGE": "Purge request has been created for this CDN Zone URL/File.",
"DATA": {
"PURGE_ID": 9182
}
}curl -X POST https://api.cachegenie.com/v1/cdn/AB12CD34E/purge \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"PURGE_TAG": "product-123"}'A whole-zone purge answers Purge request has been created for this CDN Zone., a folder Purge request has been created for this CDN Zone folder. and a tag Purge request has been created for this CDN Zone tag., each with a PURGE_ID of its own.
- 400
PURGE_URL must be a full http(s) URL on one of this CDN Zone's hostnames.: a file's URL that is not a full http or https URL on one of the zone's hostnames. - 400
PURGE_URL for a folder must be a full http(s) URL on one of this CDN Zone's hostnames, ending in * with no query string.: a folder's URL that is not one, or that carries a query string. - 400
PURGE_TAG must be one tag of up to 128 characters, with no spaces or commas.: an empty tag, a longer one, or one holding a space or a comma. - 400
Send PURGE_URL or PURGE_TAG, not both.: both were sent. - 500
Unable to Purge CDN Zone - Internal Server Error, please try again.: a write that did not go through.
What a file purge matches#
The path and query string, across every hostname of the zone, every encoding and every piece of a large file. /intro.mp4 and /intro.mp4?v=1 are two files, unless the zone's CACHE_QUERY makes them one copy. The scheme and port in the URL are ignored. See Purging for folders, tags and what happens next.
Check a purge#
GET https://api.cachegenie.com/v1/cdn/{ZONE_ID}/purge/{PURGE_ID}{
"CODE": 200,
"MESSAGE": "Purge Status Returned.",
"DATA": {
"PURGE_ID": 9182,
"COMPLETE": 1
}
}- COMPLETE (Integer): 1 once every location in service has applied the purge. Poll every few seconds until it is 1 before relying on it. It stays 0 while the purge is queued and has not reached the network yet. A location that is offline applies it as soon as it is back, before it serves anything.
A purge id that does not belong to this zone answers 404 Purge not found for this CDN Zone.