Boost website performance, eliminate server load, using Cloudflare’s Page Rules
Most website owners also enable server-side caching, with WordPress sites usually using W3 Total Cache, WP Super Cache, Hyper Cache, or other popular plugins. These plugins lessen the server load by serving non-dynamic flat HTML that is generated by WordPress, and requests for the same URL that is already available as HTML is served without needing it to execute any of the PHP code or MySQL database queries that are usually involved in every page load.
What most website owners don’t know is that there is a simple way built right into Cloudflare, using Page Rules, that can also cache not only static files, but the very same HTML files right on the Cloudflare CDN, so there are no requests to the web server for any number of page requests – only when refreshing the cache will Cloudflare hit the web server. This will boost your website performance even more, because it’s not dependent on any response from your web server – and shared hosting is very common to have higher first-byte response times, simply due to the number of accounts most web hosts put on a single server. You can still use other caching plugins to help performance when refreshing the Cloudflare full-page HTML cache. Be aware that Cloudflare’s normal caching under the caching tab does not have the “Cache Everything” option, only Page Rules offer that option on a URL pattern.
Please note, for websites running WordPress, you must create a rule that also tells Cloudflare not to cache the HTML from the /wp-admin/ administrator area or /wp-login.php login form, otherwise the administrator dashboard and login form will have issues.
So here’s the steps and two exact rules to add to Cloudflare’s Page Rules that we’ve tested and work great with WordPress, please enjoy and share!
- Log into Cloudflare. Next to your domain name(s), click the drop-down box, and click on Page Rules
- Now, set up as the very last rule so it runs after all other rules, the rule for HTML caching of the rest of the site. In the rule pattern box, type in “*domain.com/*” and then Custom Caching, choose the magic option “Cache Everything”. This sets Cloudflare to cache the HTML as well as usual static files! Then, set the Browser Cache Expire TTL to 30 mins or 1-2 hours. This will allow Cloudflare to refresh it’s cache across all it’s edge servers, so edits take effect within that time. Again, be sure to set Rocket Loader to Off. Click Add Rule.
That’s it! You’ve just boosted your website performance, and virtually eliminated your web server load to near-zero, no matter how much traffic is hitting your website. Your search engine rankings could be improved, your web hosting costs could be reduced (if based on traffic/bandwidth/visits or CPU), and your visitors are more likely to stick around longer and share your content, based on your site consistently loading faster and without any delays.
If you run into any issues, remove the cache everything rule, or try adding additional rules above it (giving it a higher priority) to exclude other areas of your website, like “*domain.com/shop/*” for e-commerce areas, etc. All dynamic, always changing content areas should have exclusions added for them.
The free plan allows for up to three page rules. The Pro plan allows for up to 20 rules, and adds SSL support using their wildcard certificate, so that’s the plan for most businesses. Cloudflare also often proactively offers filtering of WordPress vulnerabilities in their Web Application Firewall (WAF), making their service even more valuable, and has a quick and easy sign up, give them a try and let us know how it works for you. These aren’t affiliate links, it’s just a highly recommended service.
We hope you enjoy and faster website, and share this tip with your friends and colleagues.