Cloudflare Page Rules is a Cloudflare feature that is not widely used by users, even though this feature is quite powerful. Cloudflare Page Rules allow us to control how Cloudflare treats our site URLs.
By default Cloudflare does not cache web pages, either static or dynamic. Only static files are cached by Cloudflare, such as image files, css, javascript, etc. So if a visitor accesses your site, Cloudflare will immediately be forwarded to your site's server, except for the static files that I mentioned above.
For sites that are not too many visitors it may not be a problem, but if your site is busy with lots of visitors; it will be a problem on the server side. CPU load will increase, so will bandwidth, disk I / O, etc.
With Page Rules, we can instruct Cloudflare to cache the pages of our site, whether all pages or part of it. With web pages served by Cloudflare servers, server performance will automatically be light. And because server resources are not used much, the server can automatically serve more site visitors, save bandwidth, and you can install more WordPress sites to the server.
Configure Cloudflare Page Rules
I assume your site is configured using Cloudflare, and we just need to go to the Page Rules menu.
Configure the Page Rules as below:
Configuration details can be seen below.
NOTE: The first and second configuration positions must be above this last configuration.
Do a test, whether Cloudflare has cached our WordPress site pages, do it by running a command prompt (CMD) or Windows PowerShell, and run the command:
curl -I https://yourdomainname.com
Check the output of the command, and if there is a sentence CF-Cache-Status: HIT, means that your webpage has been cached by Cloudflare.
Benchmark Test
Just like in my previous writing, EasyEngine v4 Install Tutorial & Benchmark Results, we will benchmark our server and site performance with LoadImpact; with 100 users and a duration of 15 minutes. And the results are as follows:
The mean response time was 12.52 ms, and 238370 requests were successfully created with an average of 265 requests per second. And the highest recorded CPU load was only 0.16!
Maybe the results of the request wouldn't be as high if we didn't use Cloudflare, like in this test. However, the bottom line is, the response time is much smaller and the CPU load is very low, this is an impressive value. It's almost as if the server isn't performing at all. All requests are served by Cloudflare servers.