Activating Ludicrous Speed: Combine CloudFlare With a CDN on Your Blog

Activating Ludicrous Speed: Combine CloudFlare With a CDN on Your Blog

Tutorial Details
  • Program: WordPress (with W3 Total Cache)
  • Version: 3+
  • Difficulty: Beginner
  • Estimated Completion Time: 45 Minutes (may be spread out due to nameserver change)

If you’re trying to speed up your blog, you’ve probably used techniques such as optimizing your images, getting rid of unnecessary plugins and scripts, and minifying your CSS and JavaScript. However, optimizing the content on your local server can only go so far. The next step in the blog speed game is taking advantage of Content Delivery Networks (CDNs).

What is a CDN? Basically, it’s a service that stores certain elements of your site (pictures, JavaScript files, CSS files) and distributes them across a network of geographically dispersed servers. When a visitor hits your site, the CDN will determine the server on their network closest to the visitor and serve your content from there. This can really cut down on your load times!

CloudFlare is a very popular and free CDN that you can use for this purpose. Using CloudFlare alone can result in good loading time decreases on your blog. However, you can decrease these load times even more by combining CloudFlare with a “full” CDN. I’ve been using it in conjunction with MaxCDN for a few months over at my blog, College Info Geek, and I’ve had great results.

In this tutorial, I’m going to show you how to combine these two services on your own blog by using W3 Total Cache. Since CloudFlare is free and MaxCDN is not, I’ll go through CloudFlare first in case you just need a free option. Here we go!


Step 1 Install W3 Total Cache

Before you start creating your CloudFlare account, you’ll want to install and configure the W3 Total Cache plugin on your blog. This is a plugin that takes a little bit to configure. You can follow WPBeginner’s excellent setup tutorial to get all your settings correct before proceeding.


Step 2 Create a CloudFlare Account and Add Your Site

Head over to the CloudFlare website and create an account using your email address and the username of your choice.

Once you’re signed up, it’s time to start getting your website set up with CloudFlare. Note: Some web hosts include an automatic CloudFlare activation option in your cPanel. I strongly suggest you DON’T use this option – I tried it at first and my site ended up going down for three days because of a domain propagation issue. Doing the manual setup is really easy and will help you avoid any downtime or headaches!

Ok, right now you should see a screen that looks like this:

Add your site to CloudFlare

CloudFlare will start scanning your site’s DNS setup, and you’ll get to watch a nice little commercial while that happens. Fun times. Once it’s done (about 45 seconds or so), you can move on to the next step in the process.

Since you’re changing nameservers, it could take up to 24 hours for CloudFlare to become active on your site.

You should now see a page displaying what CloudFlare thinks is in your DNS Zone File. You need to access your actual DNS Zone File and make sure all the entries have been transferred over. This file can be accessed via your website’s cPanel (or similar admin panel). If you can’t find your DNS zone file, contact your host’s support and ask them where you can locate it.

Step 3 lets you choose which A and CNAME records you’d like CloudFlare to control. By default, the A record for your domain and the CNAME record labeled “www” should be the only ones highlighted. I recommend keeping this setting and continuing on.

Finally, Step 4 gives you new nameservers that you need to use for your domain. To swap out your old ones and plug in these ones, head over to your domain registrar’s website and go to your domain manager. If you’re using GoDaddy, you should see a button labeled “Nameservers” right in the domain manager. Other registrars should have a similar tool.


Step 3 Add Your CloudFlare Details to W3 Total Cache

You’ll receive an email once your domain has been propagated to the new nameservers you entered. Once this happens, you’ll be able to access your CloudFlare options. Now it’s time to add your CloudFlare details to W3 Total Cache and start reaping the benefits.

Log in to your CloudFlare account and go to the Account tab. Here you’ll be able to see your Account Email, Username, and your unique API Key. Specifically, you’ll need your Account Email and unique API Key for this part.

Head over to your WordPress Dashboard and find the option labeled Performance. This is the settings panel for W3 Total Cache. On the default General Settings tab, scroll down to the section titled Network Performance and Security powered by CloudFlare. Execute the following steps:

  • Click the checkbox labeled Enable
  • Fill in the email address you used for your CloudFlare account
  • Paste in your API Key
  • Fill in your domain name
  • Set your security level to whatever you deem appropriate. Personally I set it to low. I’ve found that setting it to anything above this seems unnecessary and can actually result in false positive blocks.
  • Make sure Development Mode is off unless you’re making design changes to your site.
  • Click Save all settings.
w3 Total Cache CloudFlare settings

Awesome! You’ve got the first part done. If you want to keep this a no-cost ordeal, you can go ahead and stop right here. Just having CloudFlare should result in a good speed boost for your site. If you want to get even more speed for free, check out the WordPress Speed Quickstart Guide for more tips.

If you want to maximize your potential, however, read on. Next we’ll be implementing MaxCDN.


Step 4 Sign Up for MaxCDN

Alright, so you want to take the plunge and integrate two CDN solutions on your blog. Sweet. Like I said above, I’ve been doing this for about four months now. So far, the combination has worked really well and my site is really snappy (especially for being image-heavy).

Ok, so the first thing to know about MaxCDN (or any “full” CDN) is that it costs money. It’s not wildly expensive, but it costs more than a coffee. So, should you use it? Here’s some guidance:

MaxCDN is generally faster than CloudFlare. As a dedicated CDN, it has more infrastructure set up for serving content as locally as possible. So I think the decision on whether to use it or not should be based on your traffic and your page sizes. Do you have a lot of images and media you’re serving up? Do you have a very visual design with lots of elements that have to load? All these things can increase load times. What about your audience? Are you getting 10 visits a day or 10,000? The more traffic you have, the more important it is that your site be optimized for speed. MaxCDN will take some of the bandwidth load off of your server, so that’s a consideration as well.

If you’ve decided that it’s worth your money, head on over to MaxCDN.com and click the signup button. Choose the Pay as You Go option (you’re probably not big enough for Enterprise, and if you are you should probably talk to MaxCDN themselves about implementation!). The base price for this option is $39.95, but you can get it down to about $30 using coupon codes. For this price, you get one terabyte of CDN bandwidth. This is where CloudFlare integration really comes in handy; by using both, I’ve managed to use only 92GB in the past four months (and this is with 30,000-40,000 pageviews a month). At this rate, the bandwidth should last 3.5 years (although traffic growth will lower this). $30 for 3.5 years isn’t too bad at all.

Once you’re signed up and have your account, go ahead and log in. In order to get MaxCDN delivering your site’s content, you need to set up a zone. Follow these steps to do just that.

  • In your dashboard, go to the Manage Zones tab.
  • You should see a box labeled Pull Zones. Click Create Pull Zone.
  • Fill in your Pull Zone Name. This can be whatever you want.
  • In Origin Server URL, input your entire URL including http://.
  • Enter a Custom CDN Domain. I’d suggest cdn.yourdomain.com.
  • Your Label can be anything you want.
  • Make sure Compression is checked.
  • Click Create.
Create Pull Zone

Step 5 Set Up MaxCDN in W3 Total Cache

The last step in this tutorial is enabling your CDN in W3 Total Cache and customizing it. To do this, go back to the General Settings tab of W3 Total Cache on your blog and scroll down to the section titled CDN.

  • Click Enable.
  • Set your CDN type to NetDNA/MaxCDN.
  • Click Save all settings.
Enable MaxCDN

Next, head over to the CDN tab of W3 Total Cache. Here you’ll tweak the CDN settings to get everything working correctly. Everything under the General section should be left as is – just make sure all the boxes are checked except the last one.

The Configuration section is where you’ll do the most work here. Follow these steps to get it set up correctly:

  • Fill in your API ID and API Key. You can find these by logging into your MaxCDN account, going to My Settings, and going to the API tab. The ID and key will be listed there.
  • Leave the SSL support option as Auto.
  • Replace your site’s hostname with the CDN domain you created (cnd.yourdomain.com).
  • Click Save all settings.
MaxCDN config

Just one last thing to do! Under the Advanced section, check the box at the bottom labeled Set cookie domain to “yourdomain.com”. Everything else can be left alone; if you find that the CDN is having problems with a certain file after you’re up and running, you can remove its filetype later. You’re done!


Conclusion

Now you have a blog powered by both CloudFlare and MaxCDN. You should notice significant speed improvements, which you can make even better by doing things like minifying your CSS and JavaScript, using WP Smush.it on your photos, and minimizing plugin usage. Enjoy your speedy new blog!

Have you had experience with CloudFlare, MaxCDN, or any other content delivery network? Share your experiences with us in the comments below.

Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more
  • http://ReviewOfWeb.com/ Ankur

    While CloudFare may be good for speeding up a blog but beware of its issue with Google Adsense.
    Many bloggers across the globe have reported the drop in adsense earnings and potential issues with it.

    • http://wp.envato.com/ Japh Thomson
      Staff

      Thanks for your comment, Ankur. Please see Damon from CloudFlare’s comment below about this.

  • http://www.jaskni.com JASKNi

    How about WP Super Cache?
    (and… I am the first one?)

    • http://collegeinfogeek.com Thomas Frank
      Author

      I actually used WP Super Cache for a long time before I switched. I don’t recall it having built-in tools for either CDN. Also, seriously, W3 Total Cache is a lot better and is worth the switch. You get a lot more control.

      • Tiger

        You can add CDN to super cache

        in fact maxcdn have a guide for using super cache with their service.

        I’m using super cache and get much better results than with Total Cache.

  • http://alihussain.me/ Ali

    Hi, Is it really important and necessary to use MaxCDN?

    • http://collegeinfogeek.com Thomas Frank
      Author

      Hi Ali,

      As I mention in the tutorial, you’ll still greatly benefit from CloudFlare alone. If you’re not sure about using MaxCDN, I’d suggest just trying out CloudFlare for a while and seeing if it meets your needs.

  • http://www.paulund.co.uk Paul

    Hi thanks for this article.

    I’ve been using Cloudflare for a while now and really like the service.

    I’ve been looking into maybe putting a full CDN service with it to help with speed, but I have been unsure about the prices. Because the services of pay as you go I never know how much I would be paying. Thanks to this article pointing out that you only used 92GB in 4 months I really think the pay as you go option won’t be a problem anymore.

    Have you seen a big difference in speed times?

    Has this helped in increasing your position in Google?

    Thanks
    Paul

    • http://collegeinfogeek.com Thomas Frank
      Author

      Hi Paul,

      I definitely saw an difference in my site’s speed. At first, I didn’t really see a change at all, and I was really frustrated – until I figured out that my Javascript notification bar was the culprit. Once I removed that, the site became a racehorse.

      As for my Google rankings, I can’t really be sure if the speed improvements are responsible for them. I don’t really test individual things on my site when it comes to SEO or analytics – I just try to improve as much as I can and see if it gets better :)

  • zet

    thanks for this article

    just one question : when is it worth to use a CND ?
    if blog not on a dedicated server, page size above 1Mo , load time above 2sec or monthly page views above 10K ?

    ps: i have tested your blog collegeinfogeek.com with ‘page speed’ on and your score is 85/100 only..
    all your images on the cdn wasnt put in the browser cache.

    details there : http://gtmetrix.com/reports/collegeinfogeek.com/ZcZXUUyd (section Leverage browser caching)

    so first check your htaccess and then use a cdn

    ps bis : you can win 20% on your jpeg file size, with jpegmini.com free service.

    Regards

    • http://collegeinfogeek.com Thomas Frank
      Author

      Hi Zet,

      The reason I’m using both is mainly because I’m on a shared server and I don’t want to switch. I have a reseller account and have a few clients from my high school web design days that basically keep my hosting free, so I use the leftover space for my blog.

      My page size is also over 1mb because of all my images, so for me the speed increases were needed.

      GTMetrix was the main speed tool I used when working on optimizing my site. The main reason I only have that score (which is actually still pretty good) is because GTMetrix actually doesn’t recognize CDN’s unless you do some special setup, and I didn’t want to bother with that. Also, I haven’t gotten into doing CSS sprites and some other things. I think if I put a bunch of time into it, I could increase the score a bit; however, I’m starting to run into diminishing returns. The site is pretty fast as is, so I’m happy with my current setup :)

  • http://pippinsplugins.com Pippin

    Great tutorial Thomas! I went ahead and got Cloudflare and MaxCDN setup on my site :D

    • http://collegeinfogeek.com Thomas Frank
      Author

      Great! I checked out your site and it seems pretty snappy :)

  • http://www.newsilike.in Bharat

    I really loved this tutorial…thnkx for making me understand how this plugin works…!

  • http://cloudflare.com Damon Billian

    “While CloudFare may be good for speeding up a blog but beware of its issue with Google Adsense.”
    The only product we have that might impact AdSense is Rocket Loader (we’re working on potential fixes for this). You should not turn the Rocket Loader product on as one option, or you can include a script tag so Rocket Loader doesn’t touch that script. Please see: https://cloudflare.tenderapp.com/kb/cloudflare-website-optimization-and-speed-features/how-can-i-have-rocket-loader-ignore-my-scripts-in-automatic-mode

    It is also highly recommended that you install mod_cloudflare.
    http://www.cloudflare.com/wiki/Log_Files

    “I went ahead and got Cloudflare and MaxCDN setup on my site”
    Definitely no conflict with CloudFlare and MaxCDN. I would just make sure that you have the CDN subdomain for MaxCDN added in your DNS zone fle (settings->DNS settings).

    Tip: Don’t activate Minify options at both CloudFlare and any caching plugin you use (this often breaks things). Please choose only one or the other.

    • http://wp.envato.com/ Japh Thomson
      Staff

      Thanks for stopping by, Damon! Really great to have you contribute to the discussion here, and also thanks for the tip regarding Minify options :)

  • http://rubiverse.net Adam

    Hi,

    Why is it necessary to run CloudFlare AND MaxCDN. Don’t you think that’s a little overkill? If you’re using CloudFlare for the CDN, why do you need MaxCDN as well (and visa versa).

    Also, you mentioned:

    MaxCDN is generally faster than CloudFlare. As a dedicated CDN, it has more infrastructure set up for serving content as locally as possible.

    Where did you get this from? CloudFlare runs a larger network than MaxCDN (CloudFlare has 14 PoPs vs MaxCDN’s 11) and they push much more traffic than MaxCDN does.

    • http://collegeinfogeek.com Thomas Frank
      Author

      Hi Adam,

      I initially got this idea from an article at The Web Hosting Hero blog: http://www.thewebhostinghero.com/articles/case-study-wp-maxcdn-cloudflare.html

      The author posted the performance tests and showed that combining MaxCDN and Cloudflare is the fastest. I don’t think he ever got around to writing a tutorial on it though, so that’s why I made one :)

  • http://ecreations.mu ashvindx

    @adam cloudflare is a free service. even if maxcdn has less PoP’s, they should be having better and faster equipment.. you usually can’t compare free vs paid service…

    • http://rubiverse.net Adam

      I wouldn’t assume that. CloudFlare has lots of funding and tons of paying customer behind them. I wouldn’t be surprised if CloudFlare’s network ran circles around MaxCDN’s network.

  • Pingback: ASO Weekly Digest Feb 27- March 2 | Web Hosting Blog at ASO

  • http://tinywp.in Pothi Kalimuthu

    “$30 for 3.5 years isn’t too bad at all.”

    The initial terabyte is valid only for a year.

    Ref: Question #7 of http://support.maxcdn.com/general/pre-sale-questions/

  • Pingback: WordPress Community Roundup for the Week Ending March 3 - Charleston WordPress

  • http://roadha.us haliphax

    I’ve been using CloudFlare for about a month now, and while I really do like it, I wanted other users to be aware that there was a period of 5-7 days after setting it up that I would get CloudFlare’s 404 page for many of my site’s common resources. This has since dissipated, but it made for a pretty frustrating week.

  • http://hafizamri.com Dunia Maklumat

    nice toturial I will try on my blog,
    Thanks…

  • http://www.frequency.ie Liam (Frequency Design)

    I’m using the Cloudflare/ MaxCDN combo on almost all of my sites (where I have access to the Domain reg to make the nameserver changes) and it really does supercharge the speed of the site.

    Using Pingdom my site is always in the 90′s in terms of page speed:

    http://tools.pingdom.com/fpt/#!/s0pHMetKD/http://www.frequency.ie

    Using the two services together expands the global reach of your site. Cloudflare has more widely distributed servers but MaxCDN is very strong with in the US.

    The only caveat is to make sure that RocketLoader on Cloudflare is switched off for all of your sites as it causes a lot of trouble with various scripts and jquery resources.

  • http://www.wpbeginner.com/ Syed Balkhi

    The coupon link for MaxCDN is broken. For those who want to use a coupon, you may use the code “wpbeginner” to get the discount.

    • http://wp.envato.com/ Japh Thomson
      Staff

      Thanks for the code, Syed! Also, I’ve fixed up that link now :)

  • Pingback: DisQus Comments Not Showing Correctly with CloudFlare | elizaibeth

  • http://www.spanishvilla.com Vincent

    Why not simply suggest the Pro/paid version of Cloudflare and help support the great service they provide for free?

  • Pingback: The Ultimate Guide To Building A Personal Website | College Info Geek

  • http://www.eq2gu.com Grump

    I use this configuration, with Cloudflare and MaxCDN I was able to lower system resources by just over 20% and bandwidth by 30%! I have seen an increase of traffic, and best of all, conversions!

  • http://jamesbanks.me James

    Great article! Thanks for the tips. I’ll definitely be integrating cloudflare into my WordPress network of websites.

  • http://Eldeforma.com Jacob

    If I am a paying customer of Cloudflare should I stiil use Max CDN? Does it makes a difference?

  • http://www.reviewcenter.in Ankit

    I tried using Cloudflare with MAXCDN and using wordpress super cache plugin. But CDN then creating loading issues. Should i use W3TC plugin for using both services? Please help!! Thanks

  • http://www.techwev.com Tech Wev

    Thanks for post. I think CloudeFlare is not good enough.

    • http://evel.us/ Jarrod Mosen

      How come?

  • http://www.xcellence-it.com Xcellence IT

    Hi, great tutorial. But I didn’t understand why you use CloudFlare and MaxCDN.. as both are CDN. As CloudFlare offers few more security features and CDN too… then why you need MaxCDN?

    I would like to know what added advantage this kind of setup offers when compared with only CloudFlare or only MaxCDN?

    Will love to hear your opinion.

    • http://www.androidgadgematic.com/ Chris

      There’s a big different between these two services. CloudFlare doesn’t optimize media, it only supports javascript, CSS etc. MaxCDN deliver media and it doesn’t support javascript, CSS etc.

      • http://www.ifkknrokk.com/ Daan van den Bergh

        That’s not true. MaxCDN also caches css and javascript.

  • http://www.astronyu.com Astronyu

    @Thomas, this is a great and useful article but you have 1 misleading statement.

    “$30 for 3.5 years isn’t too bad at all.”

    MaxCDN only offering 1TB of bandwidth for 1 year only. So, if the site using less than 1TB, it’s a loss.

  • JonnoPrice

    Hey all.. one thing that hasn’t been mentioned is SSL support. The costs quickly add up if you’re after that nice green HTTPS: in your browser…

    In my opinion, Google /Chrome is bringing increasing amounts of attention to the fact that sites are not secure and I’m sure that trend is just going to continue.. “The identity of this site has not been verified”, “the page you are loading has insecure content – would you like to proceed” “Don’t load (Recommended)” are just some of the Chrome warnings that spring to mind.

    Anyway, back to my point – if you want to use CloudFront on a website that has SSL then you have to have a Pro account as minimum – which will set you back $20 a month,. I was happy to sign up to this but really really wish I hadn’t invested in a 3 year expensive Wildcard SSL Certificate for my website at $250 only a month earlier.. :-( No need to buy a SSL certificate for your website if you use a Cloudfront Pro account as you can use theirs! Wish I’d know that. Another great feature is Cloudfront have just rolled out SPDY with their Pro accounts which is great news for SSL phreaks. http://blog.cloudflare.com/spdy-now-one-click-simple-for-any-website

    Then looking into MaxCDN today I learnt that there too you need to pay $24pm if you want SSL support. There is however a promo on at the moment for the month of August (2012) – your first TB is free… which is nice.. pity about the SSL support.

    So – if you’re operating a site where you want an encrypted login etc, and you want to combine the benefits of MaxCDN and Cloudfront, then be aware you’re looking at over $40 pm…

  • Chris

    Could you expand on the point where you say that we should “Enter a Custom CDN Domain. I’d suggest cdn.yourdomain.com.” That point kind of got glossed over, but it seems like it might be important, because I can’t seem to get this to work, and I think that might be the missing piece. Do you add this in cPanel’s Simple DNS Zone Editor? If so, what do you do exactly?

    Also, what did Damon mean when he said “Definitely no conflict with CloudFlare and MaxCDN. I would just make sure that you have the CDN subdomain for MaxCDN added in your DNS zone fle (settings->DNS settings).” ? I understand that we are supposed to add an entry on the DNS settings page on Cloudflare, but what exactly do we add? Is it something like: select CNAME from the dropdown then “cdn” in the next field, which is an alias of “yourdomain.com”? Is that correct?

  • http://www.eridesktop.com eri

    thanks for your article, but is there any cloudflare alternative..?

    • http://collegeinfogeek.com/ Thomas Frank
      Author

      Not that I know of. Cloudflare does more than a traditional CDN (caching your entire site if it goes down, providing security), so I’d definitely recommend using it.

  • http://gwynethllewelyn.net/ Gwyneth Llewelyn

    Is there a way to get W3TC to work with a CDN that has a fully S3-compliant API but which is not Amazon? How would I proceed to set it up (short of hacking the plugin and changing the API endpoint on the code, which I’m reluctant to do)?

  • http://www.facebook.com/JeffAwesome Jeff Richardson

    My site started at about 8 – 10 seconds finished load time because of some external sources and lots of images. I started with cloudflare and i noticed I was getting the site to load around 4 – 5 seconds which was great… I went ahead and purchased the 1tb of max cdn. My site loads in less then 2 seconds majority of the time with rare instances it hits 4 seconds.

    I needed to switch because I’m doing a big media push for my site and I couldn’t have the site load slow on local television or for local reporters its either go fast or the site would fail…

    This tutorial was amazing and the small issues I ran into the support over at maxcdn helped out very fast. I’m very happy with things now and think i’ll stick with cloudflare and maxcdn for quite a while.

  • Pingback: Blazing Fast And Secure Website Using MaxCDN And CloudFlare Combo | Kumar Gauraw

  • niall stack

    Hi All i would be lying if i said i knew what you were all on about… I do have a wordpress site at http://www.luvprinting.ie and if you could please let me know how i can speed it up i would be really grateful….

  • http://k0nsl.org/blog k0nsl

    My dream is to craft a CDN service provided for free.

  • http://twelvetwo.net/ Clay Asbury

    Great job – using both on all my sites. Two questions: What performance level do you recommend on Cloudflare? And, any recommendations on how best to use SSL with these two in the mix?

    • http://collegeinfogeek.com/ Thomas Frank
      Author

      I keep mine on the medium setting, I believe. As for SSL, I haven’t messed around with it yet – it’s on my “todo list”, but since I’ve taken a lot of other security precautions, it’s not high-priority.

  • Chris

    If we use two CDN network with for a one blog (CloudFlare CDN+security and Max CDN), it will not cause any side effect?

  • Pingback: Die besten SEO-Plugins für WordPress » t3n - Das Magazin für Digitales Business | we love technology