Want Blazing Fast Website Speed? Hello CloudFlare Page Rules

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.

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:

  1. Cache your whole site
  2. Allows you to setup different cache levels for specific pages
  3. 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?

How to setup CloudFlare page rules

What do you know about 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!

Reginald Chan

Reginald Chan

Professional Business Consultant
Reginald started blogging in 2005 and it soon went from just a hobby to a serious occupation. He specializes in content writing, marketing, social media and SEO. He also tweaks WordPress during his free time. Reginald is also offering paid services and if you need any help, feel free to contact him and check out the services he is offering or check out his latest project, Social Media Rush - Social Media Done Right.
Reginald Chan

@SocialCopy

Top 100 #Bloggers on Triberr, @HootsuiteAPAC (MY) Ambassador, I de-mystify social media and online marketing for business owners | #Social #Media #Marketing
Inateck MP1503 Macbook 15.4-inch Case Cover Laptop Bag Felt Sleeve Review http://t.co/BH0WGXfFfa via @techwalls - 38 mins ago
Reginald Chan
Headline Name: Email: subscribed: 210 We respect your privacy Email Marketingby GetResponse

Our Sponsors

  • Deepak Singh

    Thanks for the tutorial Reginald. This helped me a lot :)

    • http://reginaldchan.net Reginald Chan

      Hi Deepak,

      Glad you find this useful mate! Wish you all the best and of course, drop me a line if you need any help :)

  • http://www.factsnfakes.in Sumanth

    Hello Regi, Thanks a lot for this tutorial bro. Completely increased my page speed score. But i have one issue after following this steps. Cannot login to my wordpress dashboard. It says you have to enable cookies. i have done everything i can, cleared the cookies, totally installed a new operating system and a lot other but still i can’t and after trying to login in the url it has a cloudflare cf parameter. So do i need to disable it bro?
    Sorry if i’m asking more ..
    Anyway thanks a lot for this :)

    • http://reginaldchan.net Reginald Chan

      Hey Sumanth,

      It is very normal for that. I believe you have used Cache Everything? Try selecting Respect Headers and it should work just fine. Now, let’s say if you still have the cookie issue (when you login), then change it to Aggresive Cache. Cache Everything is pretty crazy stuff and not all hosting providers allows that. Even with my current hosting company, it took like a few hours or various testing before I found the right settings. Haha!

      Hope this helps.

      • http://www.factsnfakes.in Sumanth

        Hello Regi, just did what you said and that trick really worked and thanks a lot man, i now also increased my page speed. You are the best Regi. Thanks a lot again and again :)

        • http://reginaldchan.net Reginald Chan

          Hey Sumanth,

          Haha you are most welcome! Glad it worked for you and it made me smile! :)

          Of course, drop me a line if you need any other help!

  • Jeevan Jacob John

    Awesome post, Reginald :D

    I do love how specific you are in this post, especially with the “FAQ/Help” section. I haven’t used Cloud flare in a while, ever since it has caused problems in my previous blog (not just once, I got errors many times).

    But, I am willing to give it a second chance. Cloud flare has helped me to improve the loading speed of my blogs.

    I have just installed Cloudflare plugin for the new blog (still setting it up, planning to launch it next month :D).

    So, this post will definitely be helpful. I have bookmarked it, will come back and ask if I face any problems. Hope that’s okay ;)

    • http://reginaldchan.net Reginald Chan

      Hi Jeevan,

      Thanks for dropping by and commenting. How have you been?

      I have sweet and sour experience with CLoudFlare. Lately, I decided to give it a go again and seems pretty good. Of course with some configuration, I was able to hit 1 sec loading speed from 1.7 sec. Pretty impressive though!

      You really need a CloudFlare plugin as you can manually do it. All you need is to change the DNS and you are good to go. Just saying :)

      Take care and come back for more ya!

      • Jeevan Jacob John

        Good :D (and busy). Still have lots to do before I launch the blog on New Year’s.

        That’s awesome, especially in a world of instant searches. It helps to be not slow.

        Yeah, the plugin is for optimization (and better protection).

        Thanks for the reply, Reginald :)

        And, sorry about my late response. Have a great weekend!

        • http://reginaldchan.net Reginald Chan

          Hey Jeevan,

          No worries mate! Glad to see your reply.

          Oh today been busy. PageRank update lol. Huge huge boost and thank you Google.

          Have a great week mate!

  • Larry

    Thanks for the help Reg, this is the first definitive writing I have found about page rules.Even CF usually sends a link to a page rather than getting deep into it. One question, (REALLY NEED an answer on this one) the 2 page rules you mention, is that the proper order, or does the admin rule get setup first. I have the exact issues mentioned, can’t login and I don’t see updates immediately after editing posts. In fact I get a message about an additional backup of post in the browser too. I am looking to get faster loads but not at the expense of admin access, outdated content or backup bloat.

    • http://reginaldchan.net Reginald Chan

      Hi Larry,

      Hey! Thanks for dropping by. The questions you have asked for:

      1. Do you need the order? Nope. Either way is fine.

      2. When you can’t login or having the browser saved thingy, it is because of the cache saved on CloudFlare is different from your Browser. This can be solved using two ways … either change the page rule setting from Cache Everything to Aggressive Cache (fastest way) or try an error by reducing the duration of the cache expire for the Edge Cache.

      In my case, setting a page rule exception for my WP-admin solves the issue. Running on Edge Cache period of 2 hours if that could help.

      Hope this makes sense to you and drop me a line if you need any help.

      • Larry Cepek

        will do, will try experimenting with the caching options. thanks again
        do I need to include the asterisks on either side of those rules as shown?

        • http://reginaldchan.net Reginald Chan

          Hi Larry,

          No worries. In regards to your question, yes … you need the (*) symbol.

          Have a great day mate.

          • Larry Cepek

            Thanks for the help. I’ve tried all sorts of configurations, but I cant access my admin panel now. * on both sides, one side, change browser expire, I’ve got the same cookie message. I need to work n=in my panel, but I don’t want to remove the page rule for my domain just to get in.

            • http://reginaldchan.net Reginald Chan

              Hi Larry,

              I know this sounds strange but did you try with clearing your browser cache? At times that works wonders. Through my experience, you could solve the issue by changing the Edge cache duration or changing it to Aggressive settings. Also, another place to look is the URL of your wp-admin. Just ensure it is the same with the one you are setting up on CloudFlare.

              Hope this helps.

              • Larry Cepek

                Thanks for looking out for me again. Clearing browser cache is a given, but it has no effect. I did use the aggressive setting to get in to my admin panel, but if I have to do that daily, it’s going to be a nuisance to change my cloudflare account constantly. Now when I can get in, my time countdown for posting crons don’t update/time down even with a reload. It all seems to be associated with the domain cache page rule. Frustrating, I can either have speed or work within my admin panel. I can’t seem to have both at the same time.

                • http://reginaldchan.net Reginald Chan

                  Larry,

                  You do not need to have any cache on your admin panel because it is backend. Try Bypass Cache for wp-admin and it should work just fine. But yes, you can use Aggressive Cache for wp-admin if you want but you will be the only one seeing that :)

                  Hope it makes sense and certainly hope the Bypass Cache will work well for you.

                  No worries to help a mate :)

  • http://www.adriennesmith.net/ Adrienne

    Hey Reginald,

    I used CloudFlare when I was with my other hosting service and I had a lot of problems with it. Now it came with my hosting service so they set everything up. I didn’t actually have to do anything on my end so I’m not sure of most of what you shared here.

    All I know is most of the time that CloudFlare message would come up that you could see a cached version of the blog but you never did. When I upgraded to another service they no longer offered it so I didn’t lose any sleep over it.

    I hear mixed things from people about this service as well as other CDN services but since I’ve used it myself I can vouch for the issues you can have.

    In a perfect world it would work beautifully for everyone. :-)

    ~Adrienne

    • http://reginaldchan.net Reginald Chan

      Hi Adrienne,

      Hey madam :) Oh I know tons of hosting services which had issues with CloudFlare. I think the core issue is the cache part. Some hosting services (premium ones mostly) have different environment when it comes to hosting. While CloudFlare works with most hosting providers, they do not guarantee it works for all.

      Until date, I received quite a few emails from readers who had issue setting it up. Most of them are coming from the gator family but mostly, they are fine with it. This guide is all about making CloudFlare cache more than what it is default to do.

      So yes, some hosting environments just can’t work well with that. Nonetheless, it is a pretty cool service though! Pros and cons … :D