Sep 16, 2024
Klara R. & Astari S.
12min Read
Sep 16, 2024
Klara R. & Astari S.
12min 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
All of the tutorial content on this website is subject to Hostinger's rigorous editorial standards and values.
Comments
April 03 2020
I am using hostinger.in hosting service. Can I use couldflare for my can. If I change nameservers to cloudflare, will I loose Hostinger.in hosting service?
April 04 2020
Hey, you will not lose Hostinger services, make sure to follow the steps written above and everything will be alright!
April 24 2020
I have followed all above-mentioned steps but I am having an error "Domain status: not pointing to our name servers". I am using hostinger domain & hostinger hosting. Please help
April 24 2020
Hi! I am not able to locate an account with us with your email to see the exact case, but this can occur if you have not added an A record in Cloudflare. A Records are necessary to direct a visitor's browser requests to an origin web server. Access your Cloudflare Dashboard and check if the A record added there is the same as the one in your Hostinger Dashboard. You can see your Hostinger DNS records in your Panel-> Advanced-> DNS zone editor. You will find the A record you need to use there.
May 04 2020
I installed free ssl certificate from cloudflare but it is not working on my website
May 04 2020
Hey, Amit, have you followed all the steps on the tutorial?
July 11 2020
Awesome step by step guidance. thank you so much.
July 14 2020
Happy to help! :)
August 05 2020
I purchased a Cloudflare service on my Hostinger account and I have a problem to set it up. Actually my website doesn't work now and Im trying to resolve the issue. Looks like DNS settings... Please HELP!
November 06 2020
Hey there Salahaddin! Hope you are having a lovely day. Once you set up CloudFlare you may need to tweak few settings based on your DNS configuration, SSL encryption etc. My help is limited via the comments here, but if you message our support team, I am sure they can help you, if your website is hosted here :)
August 07 2020
Hi I am getting an error 1000 message. I have checked and the ftp A record is correct. The nameservers I changed both within the domain and hosting. Site launching on Monday - please help!
November 06 2020
Hey there Natasha! :) Make sure to give it 24 hours before your nameservers propagate correctly. After that make sure not only the ftp A record is correct, but the @ A record needs to point to the same IP address as well! Good luck!
August 09 2020
I done it. But i don't know why sometimes i got error my domain not pointing. Or SSH failed . . . I have to restored default my DNS. Sometime oneday my site went down 5 6 times. Could you have any other advices for me?
November 11 2020
Hey there! I am not sure what steps could a mistake appear on, but please feel free to message our support team, and I am sure they will gladly help you out! :)
August 31 2020
How to use cloudflare protection from hostinger hosting site not from the cloudflare website. I saw this in my hostinger cpanel domain ( Speed up your website and protect it against DDoS attacks for Rs. 545.00 ). Should I buy this for my website? Please help me to activate cloudflare my site.
November 06 2020
Hey there! :) You can just purchase the product and click SETUP :) Then you can chose what website do you want to attach it to and it will be active.
September 15 2020
Hi! It's a informative guide but I have a query that : Which SSL Certificate we have to activate in it (Hosinger SSL or Cloud Flare SSL) ? Or can we use both at a time ?
November 11 2020
Hey Apurb. You can use both. If you do use both - set CloudFlare's encryption to Full instead of Flexible.
September 24 2020
Thanks for the article! I have a question. Is this the same as paying Hostinger SSL ($11.95 ) and Cloudflare ($9.95)? Cheers, Jimmy
November 18 2020
Hey Jimmy. CloudFlare SSL won't replace our Hostinger's SSL, as it can't fully encrypt the connection. If you are using CloudFlare, your domain is connected to CloudFlare, and then the CloudFlare connects to your host (Hostinger). CloudFlare only has the authorization to encrypt the data between the domain and CloudFlare's servers. On the topic of CloudFlare via Hostinger, when you pay the CloudFlare protection via Hostinger, your CloudFlare will be integrated directly in your Hostinger dashboard. This makes it much easier to control, and you won't need to change the DNS at all.
November 27 2020
hey.. I got hostinger cloudflare service in my hosting plan. I did setup on my domain. Should i also have to create cloudflare accout and follow all the above steps to protect my account or not.
February 09 2021
Hi there! If you got Cloudflare from Hostinger side, all you need to do is set up the service from your Home page. You won't need to point your domain to Cloudflare.com and do all the other steps from this tutorial :) If you need any further help with it, our Customer Success team will be happy to help you out via Live Chat.
June 22 2021
There's no option to configure nameservers on hostinger cPanel plans.
September 14 2021
Hi Ricardo! If you're using a Hostinger cPanel plan, you can activate Cloudflare directly from your cPanel -> Cloudflare. In case you run into any issues doing that, feel free to contact our Customer Success team!
May 25 2022
I am trying to connect a Hostinger hosted website to an existing Cloudflare account of mine, and I am being asked for my password. When I insert that, it is being rejected as incorrect. It's funny, because I can use the very same password to connect to my Cloudflare account in a new tab. Would you kindly assist me with this?
May 31 2022
Hi there! Are you sure you're using the same email for your Hostinger account as your Cloudflare account? Maybe you have 2 Cloudflare accounts with different passwords? If not, then I would suggest to start by checking if your numlock and capslock is off. If that doesn't help, you might try changing the password. If anything, feel free to reach out to our Customer Success team anytime!
September 28 2022
what DNS settings i need to change in cloudflare to connect hostinger domain, my website is created using google sites and domain purchased at hostinger. I am facing issue of host error Error Code 522 Please provide me solution for it
September 30 2022
Hi there! Your domain's DNS zone is managed where the domain's nameservers are currently pointed. If your domain is pointing to Google Site's nameservers, then you would need to point your domain to Cloudflare from your DNS zone at your hosting provider ?