How to Purge Your WordPress Cache Using Cloudflare

Caching is an important aspect of WordPress performance optimization. It allows you to serve static copies of your dynamic WordPress pages to visitors instead of rendering the full page on every request. This significantly speeds up page load times.

However, there are times when you need to purge the cache and force WordPress to regenerate fresh copies of your cached pages. For example, when you make changes to your site’s content or design.

In this guide, you will learn how to properly clear the WordPress cache when using Cloudflare.

Why Purge the Cache

Here are some common reasons for purging the WordPress cache:

  • You made changes to your site’s content, design, or functionality and want visitors to see the updated version
  • You are troubleshooting caching-related issues on your site
  • Your site was hacked and you want to purge any malicious code that might be cached
  • You want to test the impact of caching plugins and settings

Generally, it’s a good idea to purge the cache at least once per day. For sites with very frequent updates, you may need to purge more often.

Using Cloudflare Cache Purge

Cloudflare offers robust caching for WordPress sites. Its global content delivery network (CDN) caches static resources across its edge locations around the world.

To purge the Cloudflare cache for your WordPress site:

1. Log in to Cloudflare

Go to cloudflare.com and log in to your Cloudflare account that manages your WordPress site’s DNS.

2. Navigate to Caching Settings

From your Cloudflare dashboard, click on your site’s domain name to open its overview page. Next, find and click on the Caching option in the left sidebar.

This will open the cache configuration options for your site.

3. Purge the Cache

Under the Purge Cache section, you have two options to purge the Cloudflare cache:

  • Purge Everything – Clears the entire cache for your site. Use this when you made major changes across your site.
  • Purge by URL – Clears the cache only for specific pages/URLs. Use this if you only made changes to a few specific pages.

Click on the relevant purge button and then confirm your action.

It may take up to 30 seconds for the purge to complete. You will see a notification when it finishes.

Using a WordPress Plugin

Manually purging the Cloudflare cache from their interface works fine but can be inconvenient.

A better approach is to use the official Cloudflare WordPress plugin. This allows you to purge the cache directly from within your WordPress dashboard.

Installing the Plugin

First, install and activate the Cloudflare plugin:

  1. In your WordPress admin, go to Plugins > Add New.
  2. Search for “Cloudflare”.
  3. Install and activate the Cloudflare plugin by Cloudflare Inc.

Connecting to Cloudflare

Next, you need to connect your WordPress site to your Cloudflare account using your API credentials:

  1. Go to Settings > Cloudflare in your WP dashboard.
  2. Click on Sign in here and enter your Cloudflare Email and Global API Key.
  3. Click Save API Credentials.

This will link your WordPress site for cache purge access.

Purging the Cache

Now you can easily purge the Cloudflare cache right from your WordPress dashboard:

  1. Go to Settings > Cloudflare.
  2. Under the Cache Purge section, click on the big orange Purge Cache button.
  3. Select whether you want to purge everything or purge by URL.
  4. Confirm the action.

The Cloudflare cache for your WordPress site will now be purged.

Clearing Server-Side Caches

Purging the Cloudflare cache ensures fresh copies of your site are served from their global CDN.

However, cached versions may still be stored on your web server which also needs clearing.

If using a caching plugin like WP Rocket or WP Fastest Cache, use its interface to purge the server cache.

Or, if using a cache like Redis, Memcached, or Opcache, clear it either from your hosting control panel or by putting cache clearing code in your wp-config.php file.

This clears all cached copies of your WordPress site across CDNs and your web server, ensuring visitors always get the fresh, updated version.

Wrapping Up

  • Purging cached files forces WordPress to regenerate fresh copies with updated content and code.
  • Use Cloudflare’s cache purge features to clear cached site files from their CDN.
  • For convenience, install the Cloudflare WordPress plugin to purge the cache from your WP dashboard.
  • Don’t forget to also clear server-side caches for a complete cache refresh.

Caching is crucial for performance but can cause issues if not purged properly. Follow this guide to keep your WordPress cache cleared and website running smoothly.