Programmatically purge cached content.
The Purge API lets you remove cached content from all edge servers. Use this after updating content that's already cached.
POST /api/v1/zones/{uuid}/purge
Remove all cached content for the zone.
curl -X POST "https://nordiccdn.com/api/v1/zones/abc123/purge" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{"type": "all"}'
Remove specific paths from cache.
curl -X POST "https://nordiccdn.com/api/v1/zones/abc123/purge" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"type": "path",
"paths": [
"/images/logo.png",
"/css/style.css",
"/products/item-123/"
]
}'
Remove paths matching a pattern.
curl -X POST "https://nordiccdn.com/api/v1/zones/abc123/purge" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"type": "path",
"paths": [
"/images/*",
"/products/*/images/*"
]
}'
{
"data": {
"id": "purge_789xyz",
"status": "pending",
"type": "path",
"paths": ["/images/logo.png", "/css/style.css"],
"created_at": "2024-01-25T10:30:00Z"
}
}
GET /api/v1/zones/{uuid}/purge/{purge_id}
curl "https://nordiccdn.com/api/v1/zones/abc123/purge/purge_789xyz" \
-H "Authorization: Bearer YOUR_API_TOKEN"
{
"data": {
"id": "purge_789xyz",
"status": "completed",
"type": "path",
"paths": ["/images/logo.png", "/css/style.css"],
"edge_statuses": {
"cph-1": "completed",
"fra-1": "completed",
"ams-1": "completed"
},
"created_at": "2024-01-25T10:30:00Z",
"completed_at": "2024-01-25T10:30:05Z"
}
}
| Status | Description |
|---|---|
pending |
Purge job created, not yet processed |
processing |
Purge in progress on edge servers |
completed |
Purge finished on all edge servers |
failed |
Purge failed on one or more edges |
GET /api/v1/zones/{uuid}/purge
| Parameter | Type | Description |
|---|---|---|
page |
integer | Page number |
per_page |
integer | Items per page (max: 100) |
status |
string | Filter by status |
curl "https://nordiccdn.com/api/v1/zones/abc123/purge?per_page=10" \
-H "Authorization: Bearer YOUR_API_TOKEN"
{
"data": [
{
"id": "purge_789xyz",
"status": "completed",
"type": "path",
"paths": ["/images/*"],
"created_at": "2024-01-25T10:30:00Z"
},
{
"id": "purge_456abc",
"status": "completed",
"type": "all",
"created_at": "2024-01-24T15:00:00Z"
}
],
"meta": {
"current_page": 1,
"total": 25
}
}
Purge requests are rate limited:
| Purge Type | Limit |
|---|---|
| Purge All | 10 per hour |
| Purge by Path | 100 per hour |
| Paths per Request | 1000 max |
Purge after deployment:
# .github/workflows/deploy.yml
- name: Purge CDN Cache
run: |
curl -X POST "https://nordiccdn.com/api/v1/zones/${{ secrets.CDN_ZONE_UUID }}/purge" \
-H "Authorization: Bearer ${{ secrets.NORDICCDN_TOKEN }}" \
-H "Content-Type: application/json" \
-d '{"type": "all"}'
// deploy.php
$response = Http::withToken(config('services.nordiccdn.token'))
->post("https://nordiccdn.com/api/v1/zones/{$zoneUuid}/purge", [
'type' => 'all'
]);
if ($response->successful()) {
echo "Cache purged successfully";
}
// functions.php
add_action('save_post', function($post_id) {
$post = get_post($post_id);
$path = wp_make_link_relative(get_permalink($post_id));
wp_remote_post('https://nordiccdn.com/api/v1/zones/' . NORDICCDN_ZONE . '/purge', [
'headers' => [
'Authorization' => 'Bearer ' . NORDICCDN_TOKEN,
'Content-Type' => 'application/json'
],
'body' => json_encode([
'type' => 'path',
'paths' => [$path, $path . '*']
])
]);
});
Prefer path-based purging over "purge all" to minimize origin load:
{"type": "path", "paths": ["/updated-page/"]}
Combine multiple paths in one request:
{
"type": "path",
"paths": [
"/product/item-1/",
"/product/item-2/",
"/product/item-3/"
]
}
Wildcards are powerful but can purge more than intended:
/products/* # Purges all products
/products/123/* # Purges only product 123
For critical updates, verify the purge completed:
# Create purge and get ID
PURGE_ID=$(curl -s -X POST ... | jq -r '.data.id')
# Check status
curl "https://nordiccdn.com/api/v1/zones/$ZONE/purge/$PURGE_ID" \
-H "Authorization: Bearer $TOKEN"