---
title: "Clearing the cache"
description: "Clear cached content from Edge CDN by URL, path prefix, or everything at once, via console or API. Purges reach all edge nodes globally in under 200ms."
url: "https://edge.network/docs/cdn/purging"
section: "CDN"
---

# Clearing the cache

Instantly invalidate cached content across all edge nodes when you need to push updates.

## When to purge

You might need to purge cached content when:

- You've updated content at the origin and need to push changes immediately
- You've deployed a new version of your site and need to clear old assets
- You've found an error in cached content that needs to be corrected
- You've removed content that should no longer be accessible

## Cache size

Before purging, you can view the current cache size for your deployment. The **Cache Size** section shows real-time statistics about what's currently cached:

| Statistic | Example | Meaning |
|---|---|---|
| **Cached Objects** | 1,250 | Number of items in cache |
| **Total Cache Size** | 524 MB | Total bytes stored |
| **Avg Object Size** | 419 KB | Average size per object |

These statistics are aggregated across all domains in your deployment and update in real time. After a purge, you'll see these numbers decrease as cached content is removed.

![Cache Size section showing cached objects, total size, and average object size](/media/docs/control-cdn-purge.svg)

## Purge methods

### Purge by URL

Clear a specific file from the cache. Use this when you've updated individual files.

```text
https://cdn.yoursite.com/images/hero.jpg
```

### Purge by path prefix

Clear all files under a specific path. Useful for clearing an entire directory.

```text
/images/*
/assets/css/*
```

### Purge everything

Clear the entire cache for a domain. Use sparingly, as this temporarily increases origin load.

> [!WARNING]
> Purging everything causes all requests to go to your origin until the cache is repopulated. This can temporarily increase origin load and response times.

## Purging via the console

1. Navigate to your CDN deployment.
2. Click the **Purge Cache** button.
3. Select a purge method (**URL**, **Path** or **Everything**).
4. Enter the URL or path pattern (if applicable).
5. Click **Purge**.

## Purging via the API

Integrate cache purging into your CI/CD pipeline using the Edge API.

```bash
# Purge specific URLs
curl -X POST https://api.edge.network/v1/cdn/deployments/:id/purge \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "urls": [
      "https://cdn.yoursite.com/images/hero.jpg",
      "https://cdn.yoursite.com/css/main.css"
    ]
  }'

# Purge by path prefix
curl -X POST https://api.edge.network/v1/cdn/deployments/:id/purge \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "paths": ["/images/*"]
  }'

# Purge everything
curl -X POST https://api.edge.network/v1/cdn/deployments/:id/purge \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "all": true
  }'
```

> [!NOTE]
> Purge requests propagate to all edge nodes globally in under 200ms.

## Purge speed

- **<200ms:** global propagation
- **100%:** edge node coverage
- **Instant:** effect on new requests

## Best practices

- **Use versioned URLs:** instead of purging, use versioned filenames (e.g. `app.v1.2.3.js`) and update references. This is more reliable and allows for instant rollback.
- **Be specific when purging:** purge specific URLs or paths rather than everything. This maintains cache efficiency and reduces origin load.
- **Integrate with your deployment:** add cache purging to your CI/CD pipeline so it happens automatically after deployments.

## Next steps

- [Caching](/docs/cdn/caching) — Learn about cache behaviour
- [Analytics](/docs/cdn/analytics) — Monitor cache performance
