Using Cloudflare with WP Rocket (2024)

WP Rocket is compatibleand complementary with Cloudflare. You can find more information and instructions on how to synchronize WP Rocket with Cloudflare, and other useful information below.

In this Article

  • Getting started
  • How to activate the add-on
  • Development mode
  • Optimal settings
  • Relative protocol
  • Clear Cache
  • Cloudflare Cache Everything
  • Cloudflare APO
  • Cloudways' Cloudflare Enterprise plan
  • Cloudflare's HTTP/2 server push
  • Troubleshooting

Getting started

Cloudflare ≠ CDN: Do not enter Cloudflare CNAMES on the CDN tab, this will break your site!
You may use a standard pull CDN in addition to Cloudflare depending on your needs. WP Rocket has its own premium CDN service, RocketCDN, and is also compatible with most CDN providers, including Amazon Cloudfront, Bunny CDN, KeyCDN and others.If you need information abouthow to useWP Rocket with a CDN, please: Using WP Rocket with a CDN

Using our Cloudflare add-on is not a requirement in most cases, it's only a convenience. Once you've set up your Cloudflare account correctly, it will be active for your site regardless of whether you are using the WP Rocket add-on. The add-on simply provides a convenient way to configure some settings.

The first step to use them together, is adding your site to your Cloudflare account. If you haven't done this yet, follow Cloudflare's tutorial: Create a Cloudflare account and add a website. Then Change your domain name servers to Cloudflare.

Cloudflare can perform the minification process of CSS and JS files as well as WP Rocket, so we recommend you activate minification in both to get the best results.

Note: If you use the WP Rocket Cloudflare add-on, you no longer need the official Cloudflare plugin (unless you useCloudflare APO). WP Rocket provides the same functionality of providing originating IP addresses.

WP Rocket’s Cloudflare add-on

Using Cloudflare with WP Rocket (1)

Prerequisites

You must have direct access to your own Cloudflare account to get the API key information needed to configure the add-on. If you are using Cloudflare through an integration provided by your host, you may not be able to get this information and therefore you won't be able to use the add-on, but Cloudflare will still be active on your site.

In the Add-onssettings tabyou will see the Cloudflare add-on. Switch Add-on status to ON:

Using Cloudflare with WP Rocket (2)

Then click the Modify Options button. It will take you to the Cloudflare tab that has appeared under the Add-ons tab:

Using Cloudflare with WP Rocket (3)These are the settings you need to set:

Global API key

How to find your Global API key:

  1. Log in to your Cloudflare account
  2. Click the profile icon at the top right, then click My Profile
    Using Cloudflare with WP Rocket (4)
  3. Click API Tokens

    Using Cloudflare with WP Rocket (5)

  4. There you will find the Global API Key:

    Using Cloudflare with WP Rocket (6)

  5. After entering your Cloudflare password, the API key will be revealed. Copy the Global API key and paste into the WP Rocket settings.

Note: the Cloudflare Add-on works only withtheGlobal API key,other Cloudflare API tokens are not supported.

For security and privacy, only the last 4 characters of the Global API key andZone ID will be displayed on the Cloudflare Add-on page.

Define API key in wp-config.php

If it suits your use case, you can also define your API key in your wp-config.php file. This can be useful if you have several sites under the same Cloudflare account. Here is how you would add it to your wp-config.php file (remember to replace the second value in the example with your own API key):

define('WP_ROCKET_CF_API_KEY', 'put-your-API-key-here');

With the following line of code in wp-config.phpyou can also completely hide the API key field in WP Rocket’s settings if you prefer to keep it totally hidden:

define( 'WP_ROCKET_CF_API_KEY_HIDDEN', true );

Account email

Fill in the email address used on your Cloudflare account.

Zone ID

Enter your zone ID for your domain. This is found on the Overview page for your domain in your Cloudflare account:

Using Cloudflare with WP Rocket (7)

Cloudflare Add-on and Cloudflare APO

From WP Rocket 3.14, if you're using Cloudflare APO andthe Cloudflare plugin is enabled and authenticated,the Cloudflare Add-on will be dimmed,and will have different information as shown below:

Using Cloudflare with WP Rocket (8)These are the texts inside the Cloudflare Add-on when APO is used:

Your site is using the official Cloudflare plugin. We have enabled Cloudflare auto-purge for compatibility. If you have APO activated, it is also compatible.

Cloudflare cache will be purged each time WP Rocket clears its cache to ensure content is always up-to-date.

In this case, you can manage Cloudflare settings directly from the Cloudflare plugin. WP Rocket will respect those settings.

You can find more information in the Using Cloudflare APO with WP Rocket article.

Development mode

This toggles Cloudflare’s development mode on or off. Development Mode allows you to temporarily suspend Cloudflare’s edge caching and minification features.

Did you know? ActivatingDevelopment modecan be particularly useful when you are making changes to cacheable content (like images, CSS, or JavaScript), and you would like to see those changes right away.

Optimal settings

Activating this option is highly recommended. WP Rocket automatically selects a pre-defined set of options for Cloudflare to improve the performance of your site:

  • Set Cloudflare’s caching level to Standard
  • Activate Cloudflare’sminification
  • DeactivateRocket Loader(name unrelated to WP Rocket)
  • Set Cloudflare’s browser cache to 1 year

Relative protocol

Heads up! This setting should only be activated if you useCloudflare’s Flexible SSL feature.
You should NOT activate it when your WordPress site runs on full SSL!

The Relative protocol setting rewrites the URLs of static files (CSS, JS, images) to use a relative protocol ( // instead of http:// or https://).

When should I Clear all Cloudflare cache files?

By default, it’s not necessary to press this button every time you clear WP Rocket’s cache.

It will clear the Cloudflare cache, and it mostly needed for troubleshooting, in case you've made changes to your files without changing their filenames,or when you think Cloudflare is serving outdated files for whatever reason.

Cloudflare Cache Everything

When the Cloudflare Add-on or the Cloudflare official plugin are active, WP Rocket cache clearing will also purge Cache Everything's cache.

You can find this and other troubleshooting information in the Using Cloudflare Cache Everything with WP Rocket article.

Cloudflare APO

WP Rocket is compatible with Cloudflare APO, cache clearing will be synchronized if the Cloudflare plugin is enabled and authenticated. Please see more information in the Using Cloudflare APO with WP Rocket article.

Cloudways' Cloudflare Enterprise plan

If you subscribe to Cloudflare Enterprise plan within your Cloudways hosting plan, WP Rocket won't be able to synchronize its cache with Cloudflare's in this case because Cloudways does not provide you with an API key and zone ID you can add to configure our Cloudflare add-on.

You'll need to purge the Cloudflare cache yourself each time you change the WP Rocket settings, or disable WP Rocket's page caching to keep only the optimizations. See: Disable page caching.

Cloudflare's HTTP/2 server push

If you're using the Cloudflare plugin and enabling Server Push using the define('CLOUDFLARE_HTTP2_SERVER_PUSH_ACTIVE', true); constant, Cloudflare will add all resources with the rel=preload hint on the page. Including CSS files.

This behavior is not compatible with the Remove Unused CSS feature, as it goes against the purpose of theCSS optimization. Therefore, it's not recommended to use Cloudflare'sHTTP/2 server push with the constant.

In this case, the following admin notice will be displayed:

Using Cloudflare with WP Rocket (9)

WP Rocket: Cloudflare's HTTP/2 Server Push is incompatible with the features of Remove Unused CSS and Combine CSS files. We strongly recommend disabling it.

Troubleshooting

  • Rocket Loader

    The most common cause of issues when using Cloudflare is their Rocket Loader feature. If you see display issues, or JavaScript errorswhile running Cloudflare, disable Rocket Loader and clear your cache to see if this fixes the problem. (Rocket Loader is in no way related to WP Rocket.).
  • 502 error or blank page when clearing the cache

    In some cases, when the Query Monitor plugin is active and Cloudflare is running on a site, clearing the cache can trigger a 502 error or a blank page error. If you find this issue on your site, you should disable the Query Monitor plugin, or try the code snippet provided here. In general, the Query Monitor plugin should be enabled only while queries are being actively monitored.

Using Cloudflare with WP Rocket (2024)

FAQs

Can you use Cloudflare with WP Rocket? ›

From the 3.14 version, WP Rocket is compatible with Cloudflare APO, meaning that the cache clearing between WP Rocket and Cloudflare APO will be synchronized.

Should I use Cloudflare for WordPress? ›

Cloudflare provides services to optimize a WordPress website that WordPress.com site owners can take advantage of. Keep in mind that many features offered by Cloudflare are already built into WordPress.com plans, including speed optimization, caching, web analytics, security, SSL, and CDN.

What is the difference between Cloudflare CDN and Rocket CDN? ›

Rocket CDN vs Cloudflare CDN

Cloudflare only proxies the assets at the cache level using its global network of servers, while Rocket CDN servers the static files(CSS/JSS) through its CDN powered by StackPath.

Does Cloudflare speed up WordPress? ›

Cloudflare does more than offer a CDN, Cloudflare's optimisation features allow you to enhance the performance of your WordPress site beyond what a traditional CDN can do.

Can I just use Cloudflare DNS? ›

However, some people might get scared away from using Cloudflare because they don't plan to use Cloudflare's CDN or firewall services. Don't be scared! Though Cloudflare doesn't make it super obvious, you can use Cloudflare just for DNS hosting without enabling any of the other services.

What are the disadvantages of using Cloudflare? ›

Despite its popularity and wide array of features, using Cloudflare isn't without potential downsides or considerations:
  • Redundancy with Existing Hosting Features: ...
  • Dependency and Control: ...
  • Performance Overhead: ...
  • Complexity in Debugging: ...
  • Cost and Features: ...
  • Security Considerations: ...
  • Privacy Concerns:
Dec 30, 2023

Is there anything better than Cloudflare? ›

We have compiled a list of solutions that reviewers voted as the best overall alternatives and competitors to Cloudflare Application Security and Performance, including Hostwinds, Imperva App Protect, Box, and Postman.

Will Cloudflare make my site faster? ›

Our 310 data centers located across the globe provide visitors with location-based access to your website, while removing latency and improving performance. Cloudflare saves you CPU resources and bandwidth by serving your static content directly from our global data centers.

Is Cloudflare CDN really free? ›

Yes, you can use Cloudflare for free. Cloudflare's Free plan provides the most basic website performance and security features. If you need more, you can always upgrade to a higher tier plan.

How good is Cloudflare CDN? ›

Cloudflare DDoS protection secures websites and applications while ensuring the performance of legitimate traffic is not compromised. Cloudflare Web Application Firewall's intuitive dashboard enables users to build powerful rules through easy clicks and also provides Terraform integration.

Why use Cloudflare over CloudFront? ›

Cloudflare is the fastest provider in 44% of networks and over 3x faster than CloudFront. When you use the Cloudflare CDN, you're powering your website with a global network that sits within 50ms of 95% of every Internet user on Earth.

Can you host WordPress on Cloudflare? ›

If you want to host your WordPress site on Cloudflare Pages, it's essential that you convert it first into a static WordPress site before we can deploy it. In this section, we'll walk you through this process step by step with the help of a WordPress plugin, Simply Static.

Is Cloudflare slowing down my website? ›

Our experience is Cloudflare CDN is notorious for slowing down your site with 500, 501, and 520 server errors. That's probably where your TTFB errors are coming from. Cloudflare uses NGINX servers instead of Apache. This causes the lazy loading of all Gzip compressed assets.

Does Cloudflare improve SEO? ›

By leveraging Cloudflare's powerful features, website owners can enhance their SEO performance, improve user experience, and ultimately achieve higher search engine rankings.

Does Cloudflare allow jetpack? ›

​​ Default Jetpack protection from Cloudflare

php file on all Cloudflare plans to allow only Jetpack to use the xmlrpc. php?for=jetpack query string. Cloudflare does this by only allowing the IP range of Jetpack's automation systems. As such, any attempt to access xmlrpc.

How do I use Cloudflare with CloudFront? ›

To connect CloudFront to Cloudflare DNS, simply create a DNS record in Cloudflare that points to the CloudFront distribution's domain name. This operation isn't managed by Pulumi in the above example and it needs to be done manually. In the CloudFlare interface go to the DNS settings for your domain.

How do I turn on rocket loader in Cloudflare? ›

Log in to the Cloudflare dashboard Open external link . Select your account and domain. Go to Speed > Optimization > Content Optimization. For Rocket Loader, switch the toggle to On.

Top Articles
Latest Posts
Article information

Author: Kareem Mueller DO

Last Updated:

Views: 5765

Rating: 4.6 / 5 (46 voted)

Reviews: 93% of readers found this page helpful

Author information

Name: Kareem Mueller DO

Birthday: 1997-01-04

Address: Apt. 156 12935 Runolfsdottir Mission, Greenfort, MN 74384-6749

Phone: +16704982844747

Job: Corporate Administration Planner

Hobby: Mountain biking, Jewelry making, Stone skipping, Lacemaking, Knife making, Scrapbooking, Letterboxing

Introduction: My name is Kareem Mueller DO, I am a vivacious, super, thoughtful, excited, handsome, beautiful, combative person who loves writing and wants to share my knowledge and understanding with you.