---
name: azion-purge-cached-content
description: >-
  Remove a cached object before its TTL ends, by URL, by cache key, or by wildcard, from Azion Console, the Azion API, or the Azion CLI.
---

# Purge cached content

You remove a cached object before its TTL ends from Azion Console, the Azion API v4, or the Azion CLI, naming it by URL, by cache key, or by a wildcard expression, in the Cache layer or in the Tiered Cache layer.

After a purge, the next request for the object goes to the origin, stores the version the origin returns, and carries `x-cache: MISS`. For what each purge type reaches, refer to [Real-Time Purge](/en/documentation/platform/applications/cache/real-time-purge/).

---

## Prerequisites

- The URL of the object to purge, or its cache key. To read the key, refer to [Check the cache status of a response](/en/documentation/guides/application-performance/cache-and-purge/check-page-cache-time/).
- A domain that belongs to your account. A purge of any other domain is rejected.
- Access to Azion Console, for the Console procedure. Refer to [Access Azion Console](/en/documentation/guides/platform/account-and-billing/how-to-access-azion-console/).
- A [personal token](/en/documentation/guides/platform/account-and-billing/personal-tokens/), for the API procedure.
- The [Azion CLI](/en/documentation/devtools/cli/) installed and authorized, for the CLI procedure.

---

## Choose the purge type

| To purge                         | Use             | Argument                                                                 |
| -------------------------------- | --------------- | ------------------------------------------------------------------------ |
| One or more exact objects        | URL purge       | Up to 50 URLs per request                                                |
| Specific variations of an object | Cache key purge | Up to 50 cache keys per request; the only type that reaches Tiered Cache |
| Every object matching a pattern  | Wildcard purge  | One expression with `*` per request                                      |

To remove an object held in both layers, purge Tiered Cache first and then Cache, so the first layer is not refilled from a stale copy in the second.

---

## Purge through Azion Console

To send a purge from the Console:

1. **Open Real-Time Purge**

   Access [Azion Console](https://console.azion.com/) > **Products Menu** > **Real-Time Purge**.

2. **Select New Purge**

3. **Choose the purge type and the layer**

   Select the purge type that matches your argument, and the layer to clear: Cache, or Tiered Cache for a cache key purge.

4. **Enter the arguments**

   Enter one object per item for a URL or cache key purge, or the single expression for a wildcard purge.

5. **Select Purge**

A message confirms the creation. Azion queues the purge, and it appears in the purge history once it completes.

---

## Purge through the API

Each purge type is a path of its own on the purge endpoint. To send one:

1. **Send a URL purge**

   ```bash
   curl --location --request POST 'https://api.azion.com/v4/workspace/purge/url' \
   --header 'Accept: application/json' \
   --header 'Content-Type: application/json' \
   --header 'Authorization: Token [TOKEN VALUE]' \
   --data '{"items":["https://www.example.com/include/site.js"],"layer":"cache"}'
   ```

2. **Read the response**

   The API answers with HTTP `201`, `state` set to `executed`, and the items it purged:

   ```json
   {"state":"executed","data":{"items":["https://www.example.com/include/site.js"],"layer":"cache"}}
   ```

3. **Send a cache key purge**

   The `cachekey` path is the one that accepts `tiered_cache` as the layer:

   ```bash
   curl --location --request POST 'https://api.azion.com/v4/workspace/purge/cachekey' \
   --header 'Accept: application/json' \
   --header 'Content-Type: application/json' \
   --header 'Authorization: Token [TOKEN VALUE]' \
   --data '{"items":["httpswww.example.com/include/site.js"],"layer":"tiered_cache"}'
   ```

4. **Send a wildcard purge**

   ```bash
   curl --location --request POST 'https://api.azion.com/v4/workspace/purge/wildcard' \
   --header 'Accept: application/json' \
   --header 'Content-Type: application/json' \
   --header 'Authorization: Token [TOKEN VALUE]' \
   --data '{"items":["www.example.com/include/*.css"]}'
   ```

Each request answers the same way, with its own items and layer under `data`. Without `layer`, the API purges `cache`.

> **Note**
>
> One request carries up to 50 items on the `url` and `cachekey` paths, and exactly one expression on the `wildcard` path. Past either bound the API answers with HTTP `400` and error `10065`. For the other purge bounds, refer to [Applications limits](/en/documentation/platform/applications/limits/#cache).

---

## Purge through the Azion CLI

One command sends each purge type. To send them:

1. **Purge by URL**

   ```bash
   azion purge --urls "https://www.example.com/include/site.js"
   ```

   The command prints one line:

   ```text
   Purge carried out successfully
   ```

2. **Purge by cache key**

   The `--layer` flag takes `cache` or `tiered_cache`, and defaults to `cache`:

   ```bash
   azion purge --cachekey "httpswww.example.com/include/site.js" --layer tiered_cache
   ```

3. **Purge by wildcard**

   ```bash
   azion purge --wildcard "www.example.com/include/*.css"
   ```

Each command prints the same confirmation line. A rejected purge prints the API's message instead, so run the command without `--format json` to read it.

---

## Verify the purge

To confirm the copy is gone:

1. **Request the object with the debug header**

   ```bash
   curl -sI -H "Pragma: azion-debug-cache" https://www.example.com/include/site.js
   ```

2. **Read the cache status**

   The response carries `MISS`, because Azion fetched the object from the origin again:

   ```http
   x-cache: MISS from 192.0.2.10 with HTTP/2.0
   ```

A response that reaches the origin after a purge confirms the copy left the cache.

---

## Purge an object that varies

A URL purge converts each URL to one cache key and ignores content variation, so a copy that varies by cookie, device group, or image format survives it. Purge those variations by listing every key in a cache key purge, or with a wildcard that ends in `@@*` for cookie, device, and method variations, or `?*` for query-string variations.

A query-string variation is the exception a URL purge does reach, as long as the arguments are in the order the key holds them, or in alphabetical order when **Sort** is on in the cache setting. For the keys each variation produces, refer to [Cache keys](/en/documentation/platform/applications/cache/cache-keys/), and for what each purge type reaches, to [Real-Time Purge](/en/documentation/platform/applications/cache/real-time-purge/).

---

## Next steps

- [Real-Time Purge](/en/documentation/platform/applications/cache/real-time-purge.md): Every purge type, both layers, the request bodies, and the errors a purge returns.
- [Cache keys](/en/documentation/platform/applications/cache/cache-keys.md): The key a cache key purge takes, and what each variation appends to it.
- [Applications best practices](/en/documentation/platform/applications/best-practices.md#cache): Versioned object names, the alternative that needs no purge at all.
- [Azion CLI purge](/en/documentation/devtools/cli/purge.md): Every flag of the azion purge command.
