Features Pricing Reviews FAQ
Get Plugin

Cloudflare Integration

5 min read

xSpeed Cache can connect to a Cloudflare zone so that clearing your xSpeed Cache also clears the matching cache at Cloudflare’s edge. This page explains how to connect your account, set up automatic purging, and use development mode.

What this does

When you connect a Cloudflare zone, xSpeed Cache can purge Cloudflare’s cache for that zone using the Cloudflare API. With automatic purging on, every time xSpeed Cache clears its own cache it tells Cloudflare to clear too, so visitors don’t keep seeing old files from the edge.

You can also turn Cloudflare’s development mode on or off from xSpeed Cache.

Why use it

If Cloudflare sits in front of your site, it may serve a cached copy of a page even after you update it. Connecting Cloudflare to xSpeed Cache keeps the two caches in step, so an update on your site is reflected at the edge without you having to log in to Cloudflare and purge by hand.

Requirements

  • A Cloudflare account with your site set up as a zone.
  • Your Zone ID, a 32-character hex value shown on your domain’s overview page in Cloudflare.
  • Cloudflare credentials, either an API Token or your Global API Key. An API Token is scoped and recommended.

For an API Token, create one at dash.cloudflare.com under My Profile → API Tokens. It needs the Zone → Cache Purge and Zone Settings permissions.

How to set it up

  1. In WordPress, open the xSpeed Cache settings and go to the Cloudflare module.
  2. Turn on Enable Cloudflare integration.
  3. Under Authentication, choose API Token (recommended) or Global API Key.
  4. Enter your credentials:
    • For API Token: paste your token into API Token.
    • For Global API Key: enter your Account Email and your Global API Key.
  5. Enter your Zone ID.
  6. Save your settings.

After saving, xSpeed Cache can verify the credentials against your zone. If verification fails, recheck the Zone ID and the credentials you entered.

Note: Your credentials are only sent on the request to the Cloudflare API. xSpeed Cache does not log them.

Settings explained

SettingWhat it doesDefault
Enable Cloudflare integrationTurns the Cloudflare connection onOff
AuthenticationChooses how xSpeed Cache signs in to CloudflareAPI Token
API TokenThe scoped token used when Authentication is API TokenEmpty
Account EmailYour Cloudflare email, used only with Global API KeyEmpty
Global API KeyThe legacy key, used when Authentication is Global API KeyEmpty
Zone IDThe 32-character hex ID of your Cloudflare zoneEmpty
Auto-purge Cloudflare on xSpeed Cache purgePurges Cloudflare whenever xSpeed Cache clears its own cacheOn

Enable Cloudflare integration. Lets xSpeed Cache use the credentials below to verify your zone and run purges. When off, none of the Cloudflare features run. Default: off.

Authentication. Picks which credential xSpeed Cache uses. API Token is scoped and recommended. Global API Key is the legacy method that uses your account email together with the key. Default: API Token.

API Token. Shown when Authentication is API Token. Paste a token that has the Zone Cache Purge and Zone Settings permissions. Default: empty.

Account Email. Shown when Authentication is Global API Key. This is the email on your Cloudflare account. Default: empty.

Global API Key. Shown when Authentication is Global API Key. Found at dash.cloudflare.com under My Profile → API Tokens → Global API Key. Default: empty.

Zone ID. The 32-character hex Zone ID from your domain’s overview page in Cloudflare. xSpeed Cache needs this to know which zone to verify and purge. Default: empty.

Auto-purge Cloudflare on xSpeed Cache purge. When xSpeed Cache clears its own cache, such as after a post is saved, a setting changes, or you run a manual purge, this also triggers a Cloudflare purge. Default: on.

Development mode

Cloudflare’s development mode tells Cloudflare to bypass its cache and pull files straight from your server. It is useful while you are actively making changes and want to see them right away.

xSpeed Cache lets you turn development mode on or off for your connected zone.

Note: Cloudflare automatically turns development mode off again after 3 hours. That is Cloudflare’s own behavior. xSpeed Cache does not change or extend it.

Best practices

  • Use an API Token rather than the Global API Key when you can. A token is scoped to only what xSpeed Cache needs.
  • Keep Auto-purge on so your edge cache stays in step with your site after updates.
  • Turn on development mode only while you are actively changing the site, and remember it switches off by itself after 3 hours.

Troubleshooting

Verification fails. Recheck the Zone ID, which must be the 32-character hex value from your domain overview. Confirm the credentials are correct, and for an API Token confirm it has the Zone Cache Purge and Zone Settings permissions.

Cloudflare is not purging after I update a post. Make sure Enable Cloudflare integration is on, that a Zone ID is set, and that Auto-purge Cloudflare on xSpeed Cache purge is on.

Cloudflare is being purged twice. The official Cloudflare plugin also auto-purges. If you run both, keep auto-purge enabled in only one to avoid duplicate API calls.

FAQ

What is the difference between an API Token and the Global API Key? An API Token is scoped to specific permissions and is the recommended option. The Global API Key is a legacy credential tied to your whole account and is used together with your account email.

Does turning on Auto-purge clear the whole Cloudflare cache? The auto-purge triggered by xSpeed Cache clears the cache for your connected zone.

  • Setting Up a CDN
  • Purging the Cache
  • How to Enable Page Cache