BerqWP Core Web Vitals Solution

How to Connect Cloudflare Edge Cache to BerqWP

If your site runs behind Cloudflare, you can connect it to BerqWP so your cached pages are served straight from Cloudflare’s servers, close to every visitor. BerqWP sets up the Cloudflare cache rule for you and clears Cloudflare’s copy of a page whenever that page changes. You never have to purge Cloudflare by hand.

This works on every Cloudflare plan, including Free.

Before You Start

You need:

  • A site that already uses Cloudflare, with the orange cloud (proxy) turned on for your domain
  • Access to the Cloudflare account that manages your domain
  • Admin access to your WordPress site

Step 1: Create a Cloudflare API Token

BerqWP connects with an API token. A token only has the permissions you give it, so it’s safer than your Global API Key.

  1. Log in to dash.cloudflare.com.
  2. Click your profile icon in the top right, then My Profile › API Tokens.
  3. Click Create Token, then Create Custom Token at the bottom.
  4. Give the token a name you’ll recognize, like “BerqWP”.
  5. Under Permissions, add these three rows:
PermissionWhat to pickWhy
ZoneReadFind your domain
Cache SettingsEditAdd the cache rule
Cache (“Grants access to purge cache”)PurgeClear pages
  1. Under Zone Resources, choose Include › Specific zone and pick your domain.
  2. Click Continue to summary, then Create Token.
  3. Copy the token. Cloudflare shows it only once.

Why these three? Zone Read lets BerqWP find your domain in Cloudflare. Cache Settings Edit lets it add its cache rule. Cache Purge lets it clear a page from Cloudflare when the page changes.

Step 2: Connect Cloudflare in BerqWP

  1. In WordPress, go to BerqWP › Integration.
  2. Paste the token into the API token field.
  3. Click Connect Cloudflare.

BerqWP finds the zone that matches your site’s domain, adds its cache rule and clears Cloudflare’s cache once, so visitors start from fresh pages. When it’s done, Cloudflare Edge Cache shows Connected, along with your account and zone.

If your token can see more than one zone, the Zone field becomes a dropdown, so you can switch zones later without pasting the token again.

What BerqWP Sets Up in Cloudflare

BerqWP adds one cache rule called BerqWP cache rules to your zone. You’ll find it in Cloudflare under Caching › Cache Rules. It tells Cloudflare to:

  • Cache your pages at the edge. Only pages BerqWP serves from its own cache are kept, so Cloudflare never stores a page BerqWP hasn’t optimized.
  • Skip logged in users. Admins and editors always see the live site.
  • Skip the admin area, the REST API and sitemaps.
  • Skip addresses with URL parameters, like search results or filtered shop pages.
  • Keep the browser cache short. Browsers keep a page for 10 minutes, so visitors see your updates quickly. Without this, Cloudflare’s default would let browsers keep pages for 4 hours.

The rule only covers pages. Images, CSS, JavaScript and other files keep following your own Cloudflare settings and rules. BerqWP places its rule last in your list. Please leave it there, so your own rules for other files keep working as you set them up.

How Cloudflare Stays in Sync

BerqWP clears Cloudflare’s copy of a page on its own whenever that page changes:

  • When you edit a post or page: the page itself, its category and tag pages, its author page and its translations.
  • When you click Purge this page in the BerqWP admin bar menu.
  • When BerqWP rebuilds a page in its cache.
  • When you click Flush cache in the BerqWP admin bar menu: Cloudflare’s whole cache is cleared too.

Each page is cleared by its address and by a tag BerqWP adds to it. The tag matters when Cloudflare keeps more than one copy of a page, for example one for phones and one for computers. Clearing by address can miss those copies, the tag reaches all of them.

The clearing happens right after you click Update, so saving stays fast. Visitors see the new version within a few seconds.

To clear everything by hand, go to BerqWP › Integration and click Purge Cloudflare cache.

Check That It’s Working

  1. Open your site in a private browser window, so you’re not logged in.
  2. Open your browser’s developer tools (F12) and go to the Network tab.
  3. Reload the page and click the first request, your page itself.
  4. Under Response Headers, look for:
    • x-berqwp-cache: HIT means BerqWP served the page from its cache.
    • cf-cache-status: HIT means Cloudflare served it from its edge.

The first visit after a change can show MISS. Reload once more and it should show HIT.

Troubleshooting

“Cloudflare didn’t accept this token, or it can’t read any zone”

The token is wrong or missing the Zone Read permission. Create the token again with all three permissions from Step 1.

“None of this token’s zones match your site’s domain”

The token can’t see your site’s domain. Edit the token in Cloudflare and, under Zone Resources, include the zone for the domain your WordPress site uses.

“BerqWP couldn’t add its cache rule”

The token is missing the Cache Settings Edit permission. Add it, then connect again.

A page still shows the old version after an edit

  1. Check in a private window. Your own browser may keep a page you opened in the last 10 minutes.
  2. Check the BerqWP log. While logged in as an admin, open yoursite.com/?berqwp_logs. If Cloudflare refused to clear a page, you’ll see a line starting with “Cloudflare didn’t purge” followed by Cloudflare’s reason. The most common one is a token without the Cache Purge permission.

You updated from BerqWP 4

Click Flush cache in the BerqWP admin bar menu once after updating. This clears Cloudflare’s older copies of your pages and, on Apache servers, adds the page tags BerqWP uses to keep Cloudflare in sync.

If you connected Cloudflare with your Global API Key in BerqWP 4, that connection keeps working. To switch to a token, click Disconnect under BerqWP › Integration, then connect again with a token.

Disconnecting Cloudflare

Go to BerqWP › Integration and click Disconnect. BerqWP clears Cloudflare’s cache and removes its cache rule from your zone, so nothing BerqWP set up is left behind. Your own Cloudflare rules stay as they are.

For Developers

The integration is also available from WP-CLI:

CommandWhat it does
wp berqwp cloudflare statusShows the connected zone and the version of the BerqWP cache rule
wp berqwp cloudflare purgeClears Cloudflare’s whole cache
wp berqwp cloudflare syncWrites the BerqWP cache rule to your zone again. Use it if the rule was edited or deleted in Cloudflare

Need Help?

If Cloudflare still isn’t working after these steps, our support team is happy to take a look.