# How to Purge Cloudflare Enterprise Cache by URL or Cache-Tag

> Clear the Cloudflare Enterprise edge cache in xCloud: purge everything, purge up to 30 specific URLs, purge by Cache-Tag, or queue purges from another WordPress plugin.

Use this guide to clear cached content from the Cloudflare Enterprise edge for a site or an external domain in xCloud. You can **purge everything**, **purge specific URLs**, or **purge by Cache-Tag**. A targeted purge clears only what changed, so the rest of the cache stays warm and the site stays fast.

If your WordPress site has the automatic cache purge plugin installed, xCloud already clears the cache when you edit content. Use a manual purge for changes the plugin does not see, such as theme files, CSS, or images replaced on the server. Plugin developers can also [queue purges from their own code](#purge-from-another-wordpress-plugin). To trigger purges from your own deploy pipeline, see [How to Configure Cloudflare Enterprise Auto Purge Webhooks](/docs/how-to-configure-cloudflare-enterprise-auto-purge-webhooks/).

## Prerequisites

-   Cloudflare Enterprise is active for the domain. See [How to Activate the Cloudflare Enterprise Addon](/docs/how-to-activate-the-cloudflare-enterprise-addon/).
-   At least one domain on the page shows **Active**. The **Purge** button stays disabled until then.
-   You can manage the site, or the add-on for an external domain.

## Choose a purge type

| Purge type | What it clears | Use it when |
| --- | --- | --- |
| **Purge everything** | Every cached object for this subscription | A site-wide change, such as a new theme or a changed header and footer |
| **Purge specific URLs** | Only the listed pages and files | A few pages or assets changed |
| **Purge by Cache-Tag** | Everything your origin tagged with the listed `Cache-Tag` values | Your application sends `Cache-Tag` response headers, for example per product |

After **Purge everything**, the site can be slower for a short time while Cloudflare rebuilds the cache.

## Purge the cache

### 1. Open the Caching settings

Open the site in xCloud and select **Cloudflare Enterprise** in the site menu. For an external domain, go to **Addons → Cloudflare Enterprise Addons**, open the domain's actions menu, and select **Manage**.

Open the **Settings** tab and scroll to **Caching**. Select **Purge** on the **Purge Cache** card.

![The Cloudflare Enterprise Settings tab with the Purge button on the Purge Cache card highlighted.](/_landing/docs/purge-cloudflare-enterprise-cache-by-url-or-cache-tag-01-purge-cache-card.png)

**Expected result:** The **Purge Cloudflare Cache** dialog opens with **Purge everything** selected.

### 2. Select the purge type

Choose **Purge everything**, **Purge specific URLs**, or **Purge by Cache-Tag**.

![The Purge Cloudflare Cache dialog showing the three purge options.](/_landing/docs/purge-cloudflare-enterprise-cache-by-url-or-cache-tag-02-purge-options.png)

To purge everything, select **Purge** now. For a targeted purge, continue with step 3.

### 3. Enter the URLs or tags

**For specific URLs**, enter one full URL per line in **URLs to purge (one per line, max 30)**. Each URL must start with `https://` or `http://` and belong to a domain covered by this subscription, including `www` and subdomains of the apex.

![The URL option selected with two URLs entered, one per line.](/_landing/docs/purge-cloudflare-enterprise-cache-by-url-or-cache-tag-03-purge-urls.png)

**For Cache-Tags**, enter one tag per line in **Cache-Tags to purge (one per line, max 30)**. Tags cannot contain spaces or commas.

![The Cache-Tag option selected with two tags entered.](/_landing/docs/purge-cloudflare-enterprise-cache-by-url-or-cache-tag-04-purge-cache-tags.png)

Cloudflare matches tags across the whole zone. Use tag values that are unique to your site, so a purge does not clear another site's content.

### 4. Purge and confirm

Select **Purge**.

**Expected result:** xCloud confirms the purge. On a site page, the message reads "Cloudflare cache purge started. It may take a moment to propagate." On an external domain page, it reads "Cache purged for" followed by the domain.

## Verify the purge

Request a purged URL twice and check the `cf-cache-status` header:

```bash
curl -sI https://example.com/pricing/ | grep -i cf-cache-status
```

The first request after a purge returns `MISS` or `EXPIRED`, because Cloudflare fetches the page from your server again. The next request returns `HIT` when the page is cacheable.

## Limits

-   Up to 30 URLs or 30 tags per purge request.
-   A URL can be up to 2,048 characters and a tag up to 200 characters.
-   The manual purge does not offer prefix purges. The [auto purge webhook](/docs/how-to-configure-cloudflare-enterprise-auto-purge-webhooks/) supports them.
-   A Cache-Tag purge only works for responses your origin sent with a matching `Cache-Tag` header.

## Troubleshooting

| Symptom | Likely cause | Fix |
| --- | --- | --- |
| The **Purge** button is disabled | No domain on the page is **Active** yet. | Finish DNS verification, then try again. |
| "At most 30 entries per purge request." | More than 30 lines were entered. | Split the list across several purges. |
| "Every URL must start with http:// or https://." | A line is a path or a bare hostname. | Enter full URLs, such as `https://example.com/pricing/`. |
| "URL is not served by this Cloudflare Enterprise subscription" | The URL's host is not covered by this domain. | Purge it from the subscription that covers that host. |
| "Tags cannot contain spaces or commas." | A tag line holds several values. | Put each tag on its own line. |
| A page is still stale after purging | The page is cached in the browser, or a different URL variant is cached. | Test with `curl`, and purge each variant, such as with and without a trailing slash. |

## Purge from another WordPress plugin

The xCloud auto cache purge plugin (version 1.3.0 and later) lets other WordPress plugins, such as a page cache or a custom theme, add their own URLs to its purge. Everything queued during a request goes to Cloudflare in **one purge request** when the request ends, so your plugin does not need its own Cloudflare credentials or API calls.

xCloud installs the plugin as a must-use plugin (`wp-content/mu-plugins/xcloud-cfe-cache-purge.php`) on WordPress sites that use Cloudflare Enterprise. It purges automatically when you publish, update, trash or delete a post, when a visible comment is added, edited, approved or unapproved, and when you upload, edit or delete media.

### Update the plugin to 1.3.0

Sites that had the plugin before version 1.3.0 need the update to get these hooks. Open the site's **Cloudflare Enterprise** page. If it shows **A new version of the cache purge plugin is available**, select **Update now**. If it shows **Auto cache purge is not installed** or **Automatic cache purging has stopped working** (this usually appears after you restore a backup), select **Install now** or **Reinstall now** instead.

![The Cloudflare Enterprise page with the 'A new version of the cache purge plugin is available' banner and the 'Update now' button highlighted.](/_landing/docs/purge-cloudflare-enterprise-cache-by-url-or-cache-tag-05-plugin-update-banner.png)

**Expected result:** The banner disappears once the update finishes. A site that is already on the current version shows no banner.

### Purge specific URLs

Pass one absolute URL as a string, or several as an array:

```php
do_action( 'xcloud_cfe_purge_urls', 'https://example.com/pricing/' );

do_action( 'xcloud_cfe_purge_urls', array(
    'https://example.com/',
    'https://example.com/shop/',
) );
```

Each URL must start with `http://` or `https://`. The plugin silently skips anything else, such as a bare path like `/pricing/`. xCloud purges the URL's path and query on **every Active Cloudflare Enterprise domain of the site** (for example both `example.com` and `www.example.com`), so you only need to send each page once.

### Purge the whole site

```php
do_action( 'xcloud_cfe_purge_everything' );
```

### Take over automatic purges

If your plugin decides what to purge itself, return `false` from the `xcloud_cfe_auto_purge_enabled` filter. The plugin then stops queueing its own URLs for post, comment and media changes, but it still sends every URL your plugin queues through the actions above.

```php
add_filter( 'xcloud_cfe_auto_purge_enabled', '__return_false' );
```

The filter is read when the request ends, so you can add it from a regular plugin.

### How queued purges are sent

-   Your URLs and the plugin's own URLs share one limit of **50 URLs per request**. Above 50, xCloud purges everything for the site instead.
-   A call to `xcloud_cfe_purge_everything` turns the whole request into a full purge.
-   A call that arrives after the plugin has already sent its purge, for example from a later `shutdown` callback, goes out in a separate request instead of being dropped.
-   The request does not wait for Cloudflare, and the actions return nothing. Check the result with the `curl` test in [Verify the purge](#verify-the-purge).
-   There is no prefix action. To purge by prefix, use the [auto purge webhook](/docs/how-to-configure-cloudflare-enterprise-auto-purge-webhooks/).

If the xCloud plugin is not installed, `do_action` has no listener and the call does nothing, so your plugin is safe to ship to other hosts. To check for the hooks first, test the version constant:

```php
if ( defined( 'XCLOUD_CFE_PURGE_VERSION' ) && version_compare( XCLOUD_CFE_PURGE_VERSION, '1.3.0', '>=' ) ) {
    do_action( 'xcloud_cfe_purge_urls', $urls );
}
```

## Frequently asked questions

### When should I purge specific URLs instead of everything?

Purge specific URLs when only a few pages or files changed. The rest of the cache stays warm, so the site stays fast while the changed URLs refresh.

### How many URLs or tags can I purge at once?

Up to 30 entries per purge request. Split a longer list into several purges.

### Can another WordPress plugin purge the Cloudflare Enterprise cache?

Yes. Since version 1.3.0 of the xCloud auto cache purge plugin, another plugin can ask xCloud to clear specific pages or the whole site. xCloud sends all of these in one purge at the end of the page load. See [Purge from another WordPress plugin](#purge-from-another-wordpress-plugin) for the code.

### Do Cache-Tags only affect my site?

Cloudflare matches tags across the whole zone, so use tag values that are unique to your site.

If you run into any issues while purging the cache, feel free to reach out to our [support team](/docs/access-built-in-support-portal-in-xcloud/).
