W3 Total Cache (W3TC) is one of the top notch caching plugins for your WordPress site. It will help you to do caching and minification out of the box with CDN support from popular services. On other hand, CloudFlare is the free CDN offered with most of the hosting companies like Bluehost and SiteGround. It is a good idea to combine the power of caching and CDN to improve the speed of your site. In this article let us discuss how to connect CloudFlare CDN with W3TC in WordPress site.
What You Need?
You need the following things in order to connect CloudFlare and W3TC:
- Admin access to WordPress admin panel.
- W3 Total Cache plugin installed on your site. Check out our article on how to setup W3 Total Cache on your site.
- Free or premium CloudFlare account.
How to Connect CloudFlare CDN and W3TC in WordPress?
W3 Total Cache does not offer any default settings for CloudFlare CDN setup. In fact it recommends StackPath’s MaxCDN which is another popular CDN option for WordPress users. You have to enable an extension in W3TC, in order to use CloudFlare.
Installing CloudFlare Extension
Login to your WordPress admin panel and navigate to “Performance > Extensions” section. Here, you will find all available extensions for W3TC and activate the CloudFlare extension.
Once activated, click on the “Settings” link to go to CloudFlare settings. First you should connect your CloudFlare account with W3TC and authenticate the connection.
Click on the “Authorize” button and you will be prompted to enter the API key from your CloudFlare account.
Get API Key in CloudFlare Account
Login to your CloudFlare account and navigate to your account settings. Scroll down to “API Key” section and click on the “View API Key” button against “Global API Key“. Copy the API key into clipboard.
Connecting CloudFlare and W3TC
Now go back to WordPress admin panel and enter the API key in the W3TC authorization box.
Click “Next” button and you should see the zone as your domain name activated in CloudFlare account.
Now that you have successfully connected CloudFlare and W3TC. Click on the “Next” button to go to the complete settings page.
Configuring CDN Setup
All your existing settings from CloudFlare should appear by default. You will also have additional settings from W3TC to optimize the caching. Here we will show some important settings you should be aware of.
Under “General” section, you can enable the cache time and page cache options. Cache time is the time in minutes the CloudFlare date should be stored in W3TC cache. Page cache option allows you to flush the CloudFlare cache whenever the page content is changed on your site.
Under “CloudFlare: Caching” section, you can configure the caching level, browser cache time and other options.
Content Processing Settings
Nowadays, all hosting companies like SiteGround and Bluehost offer Let’s Encrypt SSL pre-installed on WordPress installations. SSL setup in CloudFlare account and hosting account may interfere and create problems. Therefore, ensure to setup correct SSL settings here. Also. only premium account holders are allowed to set the SSL level from W3TC settings even your host support SSL with CloudFlare.
Save all your changes once the configuration settings are completed. Remember CloudFlare works like a mediator between your server and the user. Activating CloudFlare needs DNS changes which may take up to 48 hours to propagate properly. Especially, DNS propagation with CloudFlare will take long time for sites with SSL certificates. Your site will down till the time the DNS changes are completely propagated.
Though there are many CDN services are available for WordPress, CloudFlare is one of the easy solutions. It is available free with many hosting plans and the setup is very easy. You need to change the nameservers and link your account in plugins like W3 Total Cache. You can configure all settings from the plugin and increase your site’s content delivery.