WP Rocket With Cloudflare
Using WP Rocket with Cloudflare can get a bit tricky and confusing, don’t worry, my WP Rocket CDN Guide I going to show you how to do that. however, if you are already using some sort of a CDN plugin. You don’t need to integrate it again by the wp rocket CDN tab.
After integrating the Cloudflare CDN with wp rocket, you will enjoy all the benefits of a CDN.
How To Configure WP Rocket With Cloudflare
WP Rocket is totally compatible and complementary with Cloudflare. However, you need your Cloudflare API key.
The first step is adding your site to your Cloudflare account. 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 like WP Rocket. However, there is one extra thing that WP Rocket does, and it is called concatenation. This means that WP Rocket combines files into little groups for better compatibility and performance, and that is one useful feature that is not included in Cloudflare.
We recommend you activate minification in Cloudflare as well as WP Rocket in order to get the best results.
Go to you Wp rocket ADD-ONS Panel:
After I did this, another configuration box slides open. This is where I need my Cloudflare API keys for my site. go ahead and fill in yours!
My next step is to copy paste some line of code to my wp-config.php file:
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):
With the following line of code in wp-config.php you can also hide the API key field in WP Rocket’s settings if you prefer to keep it secret:
define( 'WP_ROCKET_CF_API_KEY_HIDDEN', true );
Activating this option is highly recommended. Therefore 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 Aggressive
- Activate Cloudflare’s minification
- Deactivate Rocket Loader (name unrelated to WP Rocket)
- Set Cloudflare’s browser cache to 1 month
To sum this up
in conclusion, as you can see, setting WP Rocket with a CDN is easy! It’s totally worth a few minutes of effort. Follow my guide and set your site up with a CDN. If you want to read more about optimization you can go ahead and read these articles I’ve written about: