Mar 02, 2026
Klara R. & Astari S.
11min Read
Every second counts when it comes to a website’s loading time. Fast page speed improves user experience and rankings on search engine results pages (SERPs).
Luckily, WordPress is an extremely flexible CMS that lets you apply different improvements, including speed optimization plugins such as Cloudflare.
This tutorial will explain the steps to set up the WordPress Cloudflare plugin. We will also share the best practices when using this service for website optimization.
By the end of this tutorial, you will be able to speed up and secure your WordPress site using Cloudflare.
Download all-in-one WordPress cheat sheet
Cloudflare is a popular content delivery network (CDN). A CDN uses a group of servers worldwide to deliver websites’ content faster.
Cloudflare works by making copies of a website on proxy servers. Any request to access the website’s content will go to the server closest to the visitor’s location for faster processing.
In addition, this content delivery network service also protects your website against distributed denial-of-service (DDoS) attacks by monitoring all incoming traffic and blocking suspicious users.
Cloudflare mainly optimizes WordPress sites’ speed and security.
It can speed up your WordPress site by minimizing the distance between the visitor’s device and Cloudflare’s servers.
In addition, this CDN improves your website’s performance with features like image resizing and auto minification.
Cloudflare can also ensure your site’s data privacy by hiding your nameservers on domain registration lookup tools (WHOIS). Additionally, Cloudflare web analytics ensures security by showing the number of threats it detects and stops.
Follow these steps to set up this WordPress CDN on your site:
Important! Make sure to have access to your domain name registrar before setting up Cloudflare.
Head to the Cloudflare website and click Sign Up to create a new account. Verify your email address before continuing to the next step.

Log in to your Cloudflare account and follow these steps to add your domain name:

Important! To add multiple WordPress sites, click Learn how.


After adding your WordPress site, Cloudflare will automatically scan for common DNS records and add them to your account.
Sometimes, Cloudflare doesn’t necessarily find all records in the domain name system (DNS). Therefore, it will ask you to Review your DNS records.
First, make sure that the domain is pointed correctly by checking your A records. While checking your records, we also recommend enabling Cloudflare for www and non-www versions of your site.
To enable or disable Cloudflare for specific subdomains, toggle the button under Proxy status. Once you are done, press Continue to proceed to the next step.

Important! We don’t recommend enabling Cloudflare for cPanel, mail, or FTP, as doing so can cause DNS issues.
Cloudflare will direct you to change your nameservers. Copy both Cloudflare nameservers and head to your domain name registrar.

Depending on your domain name registrar, the steps of changing the nameservers may slightly differ. Here is how to change your nameservers with Hostinger:

Head back to the Cloudflare website and click Done, check nameservers.
Important! The domain might take up to 24 hours to propagate the new nameservers. You will receive a confirmation email from Cloudflare once the propagation is complete.
Hypertext Transfer Protocol Secure (HTTPS) is an internet communication protocol that secures the data exchanged over a computer network.
A WordPress site with a Secure Socket Layer (SSL) certificate will show a padlock and https:// instead of http:// before its URL.
Cloudflare’s SSL/TLS encryption mode helps determine how to validate the SSL certificate in your origin server.
Follow these steps to configure Cloudflare’s HTTPS settings page and protect your WordPress site against potential data breaches:
Important! If you aren’t sure which encryption mode to choose, use the SSL/TLS Recommender feature to get a suggestion.


Check if your web hosting provider offers free SSL certificates before purchasing. For instance, Hostinger’s web hosting plans include an unlimited free SSL certificate.
With the Cloudflare plugin, you can easily change its settings directly from the WordPress dashboard. First, head to your Cloudflare account to get the Application Programming Interface (API) key:


Head to your WordPress dashboard to continue configuring Cloudflare:

Now, you can configure important Cloudflare settings on your WordPress dashboard.

Some of the main features available on the Cloudflare WordPress plugin include:

Here are ten key Cloudflare configurations for your WordPress site:
The Auto Minify feature minifies JavaScript, CSS, and HTML files by removing unnecessary characters to improve page load times.
Cloudflare removes comments and empty lines from HTML files. For JavaScript and CSS, Cloudflare will only minify the cached files. Therefore, make sure to purge cache to see the changes on your WordPress website.
This optimization feature is available on all Cloudflare plans. To enable it, head to Speed → Optimization → Auto Minify and select the type of file you want to minify.

Brotli is a compression feature that ensures quick data transfers between servers and browsers. It uses a dictionary to send keys instead of the full keywords.
Using the keys, Brotli compresses images, texts, and fonts to speed up page load times. On average, it has a much faster transfer time than GZIP compression.
Cloudflare uses Brotli compression as the preferred content-encoding method for all plans. If your server does not support this feature, this CDN will apply GZIP compression instead.
This feature is also available on all Cloudflare plans. To turn on this feature on your Cloudflare dashboard, head to Speed → Optimization → Brotli.

Rocket Loader shows content faster by deferring JavaScript code loading until after rendering your other content, such as texts, images, and fonts.
Cloudflare’s Rocket Loader feature mainly improves the following performance metrics for pages that use JavaScript:
Cloudflare offers this feature for all users. To enable this optimization feature, head to Speed → Optimization → Rocket Loader.

The Web Application Firewall (WAF) is one of Cloudflare’s security features that helps block potential online attacks and provide DDoS protection.
With machine learning, the WAF protects your WordPress site by preventing account takeover, stopping data leaks, and blocking logins with stolen credentials.
With this feature, WordPress users can create custom rules to control incoming traffic, such as filtering requests based on location and IP address.
To configure these Cloudflare settings, head to Security → WAF, and you will see four tabs:

Some firewall features are available with the free Cloudflare account. However, most of them require at least the Pro plan.
Cloudflare’s network settings help manage where to direct visitors and what they can do on your site. The proper configuration can improve your performance significantly. Here are some of the primary network features to consider:

Most Network features are free except for Response buffering and True-Client-IP-Header, which are available only for Enterprise plan users.
The page rules feature enables specific Cloudflare settings on your WordPress site. Cloudflare offers around 37 page rules – some are not available with the free plan.
Here are the steps to set up Cloudflare page rules:


You can create up to three page rules with a free Cloudflare account. Upgrade to the Pro version to get 20 rules. If you need more, the Business and Enterprise plans offer 50 and 125 rules, respectively.
Here are some tips to take advantage of this feature for your WordPress sites:
Always Use HTTPS
Use this rule to secure visitors’ connections by redirecting all variations of your website to the https:// version. Enter your WordPress site’s domain name in between two asterisks:
http://*example.com/*

WordPress Admin Security and Cache Levels
Protect and speed up your WordPress admin by setting the Security Level to High and Cache Level to Bypass.
In addition, disabling Cloudflare Apps and Performance helps fix errors, as these features only speed up your site’s front-end.
Enter your WordPress login URL with an additional asterisk:
example.com/wp-admin*

Bandwidth Control for WordPress Uploads
If you rarely change the files you upload to WordPress, save bandwidth by setting Edge Cache TTL to a month.
Then, change the Cache Level to Cache Everything to optimize the speed and the Browser Cache TTL to a day to show the most recent content of your site.
Here is what to use for the URL:
example.com/wp-content/uploads*

Always Online
This feature keeps your pages online if your server is experiencing downtime. Enable the Always Online feature for your most important URLs.

Email Obfuscation
Use the Email Obfuscation rule on your contact page or any page with contact information to hide your email address and prevent spam.

The image resizing feature caches image files and minimizes their dimensions to boost your WordPress site’s performance.
This feature also automatically adjusts your images for mobile optimization. By enabling this Cloudflare feature, you can maintain a consistent website appearance.
To take advantage of this image optimization feature, subscribe to the Business plan. It comes with up to 100,000 image requests per month.
Mirage helps websites load images based on the network connection and device type without altering the original resolution. For example, devices with smaller screens will show smaller images.
This Cloudflare feature speeds up loading time using the following methods:
To use this feature, you must at least have the Pro plan. Note that this feature might cause issues when displaying images with specific JavaScript code, such as for carousels and photo viewers.
This feature is only available with the Pro plan and above. The Polish feature improves your image load time by decreasing your file size using the following options:
Make sure to purge your cache when changing the polish settings to see the changes.
Caching stores copies of your static content in a temporary storage location so browsers can access them quicker.
Cloudflare can help cache web browsers to load sites faster. It also caches DNS servers to look for records more quickly.
To access this Cloudflare feature, head to Caching -> Configuration. Some of the main features include:

In addition, Cloudflare has a settings page for Cache Analytics, Tiered Cache, and Cache Reserve. Some of these settings are only available with the premium version.
Sometimes, improper Cloudflare setup or incompatible features can cause errors to your WordPress site. Here are some of the most common Cloudflare errors:
Error 520
Cloudflare error 520 happens when a server receives an invalid request. As a result, the web browser will show a “Web server is returning an unknown error” message.
An issue with the origin server is the main reason behind this error. For example, the origin server might crash or not allow connections with Cloudflare IP addresses.
Some methods to fix this issue are:

Error 521
Cloudflare error 521 shows the message “Web server is down”. This error often happens due to incorrect Cloudflare configuration, such as the wrong encryption mode with the SSL certificate.
If your WordPress site is showing this Cloudflare error, here are some methods to fix it:

Error 522
Lastly, Cloudflare error 522, or “Connection timed out” happens when the server fails to respond to requests within a specified time.
This issue also means that the Transmission Control Protocol (TCP) handshake between the server and Cloudflare has failed.
Here are some ways to fix error 522:
Setting up Cloudflare on your WordPress site is pretty simple. We have shown the steps to configure Cloudflare on WordPress:
In addition, we have also explained how WordPress users can benefit from Cloudflare’s key features, such as image resizing and caching.
Sometimes, the wrong configuration can cause errors on your WordPress site. We have also shared the most common Cloudflare errors and ways to fix them.
After setting up Cloudflare integration on WordPress, try running a speed test to check your loading time.
Hopefully, this article has helped you install and manage Cloudflare on your WordPress site. If you have any questions or suggestions, feel free to leave us a comment.
Best WordPress Plugins
Best WordPress SEO Plugins and Tools
Top Google Analytics WordPress Plugins