Purging cached resources from Cloudflare

Learn how to purge resources cached by Cloudflare using the purge methods available for your Cloudflare plan.


The Caching app in your Cloudflare dashboard allows purge of cached resources by single-file (recommended), hostname or cache-tag (Enterprise plans only), or all cached content. All customers can purge by single-file (by URL) or purge all cached assets. Cloudflare Enterprise customers can also purge using hostnames and cache-tags.

Purge by single-file (by URL)

When you choose the Purge by URL (single-file) option in the Caching app, that cached resource is immediately removed from the stored assets in your Content Delivery Network (CDN) across all data centers. Any new request for the purged asset gets the latest version from your origin web server and adds it back to your CDN cache within the specific Cloudflare data center that served the request.

Important! A single-file purge performed through your Cloudflare dashboard does not clear objects that contain:

  • Custom cache keys
  • An origin header
  • Any of these response headers:
    • X-Forwarded-Host
    • X-Host
    • X-Forwarded-Scheme
    • X-Original-URL
    • X-Rewrite-URL
    • Forwarded

You can purge objects with these characteristics using an API call (Purge files by URL).

In the data/header section of the API call, you must include all headers and cache keys contained in the cached resource, along with their matching values.

Always use UTF-8 encoded URLs for single-file cache purges.

Purging by single-file through your Cloudflare dashboard

1. Login to Cloudflare and select the site with the resources to purge.

2. Click the Caching app.

3. In the Purge Cache pane, click Custom Purge.

The Custom Purge dialog box appears.

4. Select URL in the Purge by field.

5. Enter the appropriate value(s) in the text box, using the format type shown in the example.

6. Perform any additional instructions to complete the form.

7. Review your entries.

8. Click Purge.

Purge everything

To maintain optimum site performance, we strongly recommend using single-file (by URL) purging instead of a complete cache purge.

Purging everything immediately clears all resources from your CDN cache in all Cloudflare data centers. Each new request for a purged resource returns to your origin server(s) to validate the resource. If Cloudflare can't validate the resource, it fetches the latest version from the origin server and replaces the cached version. When a site with heavy traffic contains a lot of assets, requests to your origin server(s) can increase substantially, and may result in slow site performance.

Purge everything through your Cloudflare dashboard

Reminder: We highly recommend performing single-file purges.

1. Login to Cloudflare and select the site with the resources to purge.

2. Click the Caching app.

3. In the Purge Cache pane, click Purge Everything.

A warning dialog appears.

4. If you agree, click Purge Everything.

Purge cached resources through the API

You can automate or script cache purges using these Cloudflare APIs:


Purge using Cache Tags (Cloudflare Enterprise only)

Cache-Tag purging makes multi-file purging easier. You can perform bulk purging by adding cache-tags to your assets (web pages, image files, and so on).

Hostname and Tag purges are only available in Cloudflare Enterprise.

How Purge by Cache Tags work

This is the general workflow for using cache tags:

  1. Add tags to the Cache-Tag HTTP response header from your origin web server for your web content (pages, static assets, and so on).
  2. Ensure your web traffic is proxied through Cloudflare.
  3. Cloudflare associates the tags in the Cache-Tag HTTP header with the content being cached.
  4. Use specific cache-tags to purge your Cloudflare CDN cache of all content containing that cache-tag, through your dashboard or using our API.
  5. Cloudflare forces a cache miss on content with the purged cache-tag.
Be careful what you purge! A cache miss can cause execution delays by requiring a fetch from your origin server.

Add Cache-Tag HTTP response headers

You add cache-tags to your web content in Cache-Tag HTTP response headers. You use HTTP headers to allow the client and the server to pass additional information in requests or responses. HTTP headers consist of a specific case-insensitive name followed by a colon ( : ) and the valid value, for example, Cache-Tag:tag1,tag2,tag3. As shown, you use commas to separate the tags when you want to use multiple cache-tags.

When your content reaches our edge network, Cloudflare:

  • Removes the Cache-Tag HTTP header before sending the response to your website visitor.

Your end users never see Cache-Tag HTTP headers on your Cloudflare-enabled website.

  • Removes whitespaces from the header and any before and after cache-tag names:

tag1, tag2 and tag1,tag2 are considered the same.

  • Removes all repeated and trailing commas before applying cache-tags:

 tag1,,,tag2 and tag1,tag2 are considered the same.

A few things to remember:

  • A single HTTP response can have more than one Cache-Tag HTTP header field.
  • The minimum length of a cache-tag is 1 byte.

Individual tags don’t have a maximum length, but the aggregate Cache-Tag HTTP header cannot exceed 16 KB after the header field name, which is approximately 1000 unique tags. Length includes whitespace and commas, but not the header field name.

  • For cache purges, the maximum length of cache-tags in an API call is 120 characters.
  • The Cache-Tag HTTP header must accept all valid characters allowable in HTTP headers, as specified in RFC-5987.
  • Spaces are not allowed in cache-tags.
  • Case does not matter:

Tag1 and tag1 are considered the same.

Purging using cache tags in your Cloudflare dashboard

1. Login to Cloudflare and select the site with the resources to purge.

2. Click the Caching app.

3. In the Purge Cache pane, click Custom Purge.

The Custom Purge dialog box appears.

4. Select Tag in the Purge by section.

5. In the text box, enter your tags to use to purge the cached resources.

To purge multiple cache-tagged resources, separate each tag with a comma or have one tag per line.

6. Click Purge.

Purging using cache tags or hostnames via the Cloudflare API

Read our documentation on removing cached assets from your CDN using the Purging by cache-tag or hostname APIs. You can use up to 30 cache-tags in one API call and make up to 30,000 purge API calls in a 24-hour period.

Related resources


Not finding what you need?

95% of questions can be answered using the search tool. This is the quickest way to get a response.