CloudFlare is the most popular Content Delivery Network (CDN) used by thousands of bloggers. CloudFlare makes it easy for you to integrate with nearly any CMS especially with WordPress and in most hosting environment resulted from CloudFlare partner’s program.
While CloudFlare is easy to setup and could supercharge your site in less than 5 minutes (as advertised), you could produce even faster website load speed by using CloudFlare Page Rules … which I will explain in a moment time.
BONUS: Best Web Hosting for Small Business
What is Content Delivery Network or CDN?
Content Delivery Network is a service which cache most of your static contents and store them on specific servers around the world. For your visitors, they will be noticed a much faster loading speed as these static files will be served to them from the closest location and for webmasters like you, you would be able to reduce your server loads.
The CDN servers are highly optimized to provide only one purpose; which is serving your visitors with statis contents and fast … regardless which location they are from.
For those who are wondering, static files are images (.jpg, .png, .gif), stylesheets (.css), scripts (.js) and many more.
Why do you need CloudFlare page rules?
CloudFlare page rules is for those speed junkies like me who wants to get more out of the free CloudFlare service. Basically, page rules allow you to specify which files you want CloudFlare to cache it on their servers. Of course, the more files they cache, the faster your website speed is and you would be able to save more server bandwidth.
Page Rules is a powerful new set of tools that allows you to control how CloudFlare works on your site on a page-by-page basis. CloudFlare.
CloudFlare page rules is so powerful that it can:
- Cache your whole site
- Allows you to setup different cache levels for specific pages
- Setup custom cache expiration
While CloudFlare page rules can be godly, it can easily (literally) destroy your site with tons of 404 errors and slow updates. This wouldn’t really happen in this tutorial unless you are really pushing your luck.
Most of us are using CloudFlare free account and you are entitle for 3 page rules plans free of charge. Anything more and you would need to sign up for CloudFlare pro or business plans.
>> Not using CloudFlare yet? Sign up for a free account here! <<
How to setup CloudFlare Page Rules?
Configuring CloudFlare Page Rules is easy as long as you know which URL pattern to use. This means that very specific page rules settings are applied only to that specific URL’s only.
So, what happens if you want to set a custom patterns for several strings of URL without using up all your page rule allotments?
1. Understanding CloudFlare pattern matching URLs
This is where Pattern Matching comes into play. It is a feature that allows you to create powerful dynamic custom patterns that can match a series of URLs instead of just one. The symbol used is the asterisk (*) character.
example.com/* matches:
- example.com/blog
- example.com/directory
But does not match:
- blog.example.com
*.example.com matches:
- blog.example.com
- www.example.com
But does not match:
- example.com
2. Setting up CloudFlare Page Rules
The first part is adding the relevant URL pattern which you can use from the chart above. Personally, I would advise setting up two specific URL patterns which are:
- *example.com/*
- *example.com/wp-admin/*
In the first string of URL, this is where all the extreme caching takes place. The below are the settings for this specific page rule:
- Custom caching – Cache everything
- Edge cache expire TTL – Respect all existing headers
- Browser cache expire TTL – 4 hours
- Always online – Default
- Apps – Optional
- Smart errors – On
- Performance – On
- Rocket Loader – Default
- Security – On
Now, for the second string of URL, you would need to make a cache exception for your back-end (wp-admin area). Just follow the settings below:
- Custom caching – Bypass cache
- Browser cache expire TTL – 4 hours
- Always online – Default
- Apps – Optional
- Smart errors – On
- Performance – Off
- Security – On
These are some of the very basic and safe page rule settings that will speed up your blog loading speed and ensuring that you wouldn’t face any issue on your admin area. You may change any of these settings to fit your liking or requirements.
Note:
- Adjusting the duration of Edge cache expire TTL and Browser cache expire TTL are risky as you may face issues logging in or your visitors will not be able to see the latest post even though it is published
Additional information:
Edge cache expire TTL
Sometimes cache headers are set on the server-side or by a CMS solution like WordPress. If you choose to Cache Everything, CloudFlare will respect these headers unless you choose to overwrite them. By overwriting the headers, CloudFlare will cache more content at the CloudFlare edge network, meaning a decrease in load to your server. To overwrite any default headers, choose a time from the drop-down menu. This is the refetch time for when CloudFlare checks the origin server for a new resource. Common situations where you may choose to overwrite any existing headers:
- You are experiencing large surge in traffic
- You are under DDOS attack
- You are not sure what the headers on WordPress or your server are set to
- You are using WordPress and want to easily overwrite the default settings
Browser cache expire TTL
This setting is how CloudFlare communicates with the visitor’s browser. CloudFlare will respect the headers that you give us from your web server, and then we will communicate with the browser based on the time selected in this drop down menu. For example, your origin server headers may be set to cache for 1 year. You could configure CloudFlare to respect those headers (this is done by default, unless specifically changed), and then choose a different time limit here like 24 hours. What this means is that if you ever had to change the resource over the course of the year, you could know with full confidence that all your visitors would have the new asset within 24 hours, without any additional load to your origin server.
3. Clearing old caches on CloudFlare and WordPress
By now, you should have two page rules setup for your blog. The last part would always be clearing your cache on both CloudFlare and on your blog. This is to ensure that the site is running on the latest cache version and updates.
Once this is done, allow CloudFlare and your WordPress blog to build cache over time. If you are using W3 Total Cache, it could takes up to 48 hours while Super Cache could take around 6 hours or less.
Help! CloudFlare Page Rules are not working!
Here are two of the most common symptoms that the page rules are not working properly:
- Unable to login to wp-admin
- Newly published post is not visible even after clearing cache
Through my experience, the biggest culprit for this could be the Edge cache expire settings. If you have set a very strict and long duration such as 24 hours, this means that CloudFlare will only check for new contents once every 24 hours. CloudFlare recommends a duration of 4 hours as the duration is more than enough for a normal (and average) blog site.
At the same time, it is not recommended to have a shorter duration than what recommended as it could create a lot of resources strain on the hosting servers.
Help! I am not seeing much improvement after enabling CloudFlare page rules
This is extremely common if you have a lot of JavaScript and CSS files on your site. Another option is to use CloudFlare railgun which would cost you around $200 per month aka CloudFlare Business plan. If you are running a high traffic website, I would highly recommend this as railgun technology will make your website blazing fast.
The cheaper and more affordable alternative is using MaxCDN and it only cost you $67.50 per year (with MaxCDN coupon checkout25). For your information, you can integrate MaxCDN with CloudFlare to boost your website speed. MaxCDN is a great tool for bloggers when it comes to serving static contents while CloudFlare ensures that your site is packed with bulletproof security.
>> Try MaxCDN today and get 25% discount off your total bill! <<
Does your website takes more than 2 seconds to load?
If the answer is yes, you certainly got to try the free CDN solution which is CloudFlare. If you are having around 1,000 traffic and below, CloudFlare would be more than sufficient when it comes to make your website blazing fast. With so many hosting companies already partnering up with it, I see absolutely no reasons why you shouldn’t!
Tell me what you think using the comment form below and if you like the article, I would appreciate a social share!