How do I purge my cache?

With Cloudflare, you can purge your cached content either by individual file, hostname, tag, or everything at once.


Overview

You can purge your cached resources using either the Caching app (in the Cloudflare dashboard) or the Cloudflare API. Both interfaces allow you to purge resources based on your plan, as follows:

  • All customers can purge:
    • By URL (individual files)
    • Everything
  • In addition, Enterprise customers can purge by:
    • Hostname
    • Tag

This article provides information on purging resources from the Caching app in the Cloudflare dashboard. To use the Cloudflare API directly, see the documentation.


About Purging by URL

To avoid slow site performance, Cloudflare recommends purging resources individually. This leaves all other resources cached, avoiding a fetch of any other cached content from the origin server.

Purging a single file removes it immediately. Subsequent requests for the same file will fetch the latest version from the origin server and re-add it to the CDN cache.

Important - A single file cache purge performed through the Cloudflare dashboard will not clear objects that contain:

  • Custom cache keys
  • An Origin header
  • Any of the following headers:
    • X-Forwarded-Host
    • X-Host
    • X-Forwarded-Scheme
    • X-Original-URL
    • X-Rewrite-URL
    • Forwarded

However, you can purge objects with these characteristics through an API call (Purge Files by URL). Make sure to include all the headers and cache keys contained in the cached object, along with their matching values, in the data/headers section of the API call.


About purging everything

To minimize slow performance, Cloudflare strongly recommends using single file purging instead of a full cache purge.

Purging everything clears all resources from the cache immediately. Each subsequent request for any purged resource will go back to the origin server(s) in an attempt to revalidate the resource.

Revalidating means that it won't be necessary for Cloudflare to re-cache the resource because it matches the latest version in the server. If Cloudflare can't revalidate the resource, the cached version is replaced with the latest version fetched from the origin.

If you have many assets as well as heavy traffic, you might see a substantial increase in requests to your origin and your website might slow down as a result.


Purge cached resources in the Cloudflare dashboard

To purge by URL, Hostname, or Tag:

1. Log in to Cloudflare and select the site where resources need to be purged.

2. Click the Caching app.

3. Under the Purge Cache panel, click Custom Purge. A dialog opens where you can enter details.

4. For Purge by, select URL, Hostname, or Tag.

Purging by Hostname or Tag is only available to Cloudflare Enterprise customers.

5. In the text box below enter the appropriate value(s), using the format specified on the dialog.

6. Read any additional instructions on the dialog and review your choices.

7. If everything looks correct, click Purge.

To purge everything:

1. Log in to Cloudflare and select the site where resources need to be purged.

2. Click the Caching app.

3. Under the Purge Cache panel, click Purge Everything. A confirmation dialog with a warning opens.

4. If you agree, click Purge Everything.

Not finding what you need?

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

Powered by Zendesk