Your self-hosted CDN on Facebook

Free Content Delivery hosted on Facebook

Published Oct 12, 2011 in cdn, facebook, hosting, guides

Alright, so CDN.

What is a CDN?

CDN basically means Content Delivery Network. A CDN can improve access to the data it caches by increasing access bandwidth and redundancy and reducing access latency. It’s a way to make your website load faster. In some cases, much faster simply because of the way it’s delivered.

How does CDN work?

Simple. Let’s take a look at what happens WITHOUT CDN. So your content basically will be hosted with your hosting server, say it’s hosted in Texas. Users visit your site say from London, and as usual, these contents will be delivered to your users from your hosting server. Wherever your users are located at, these contents will still be delivered to your users from your hosting server regardless. Cache on your server’s disk will only help reduce your site’s page load speed slightly as it pulls the contents from the cache which somebody else’s have accessed to previously. Hence there is a slightly performance gain there, however not much.

Now let’s see what happens if we introduce WITH CDN. With the same scenario, your users visits your site from say London and your hosting server is hosted say at Texas. With CDN in place, users will not need to download the contents from Texas but the server closest to them. Subsequent users from the same location will download the content as well from the same server, hence will reduce your page load time. Therefore, this will result in a faster load time and better user experience. Furthermore, this will also help reduce your bandwidth, loading images will not take up your servers bandwidth in this instance. CDN can be considered as one of the best practices for speeding up your site.

Let’s put this in simple terms. Take a look at this analogy. You are located at London and I am located at Texas. I have a package that I want to send you. Will it be easier and cheaper for me to deliver the package to London and you picking it up from London, or for you to pick it up from Texas? Not exactly a good analogy, but you get it right?

The result is that your website, on average, loads twice as fast for your visitors regardless of where they are located — CloudFlare

Isn’t this great?

On the contrary, CDN services aren’t exactly free. There are many CDN services like Microsoft Windows Azure, Amazon CloudFront, Akamai, MaxCDN, etc. and the list goes on. So today, I am going to show you how you can still make use of CDN on a self-hosted environment.

Note: This explanatory solely works for images and videos.

Let’s begin. CDN will cache all your static files on to the nearest Edge servers where your users request from. However, today in this short guide, I will only show you how you can cache images and videos using Facebook’s CDN. This sounds crazy, I know, but it works! Now we all know Facebook serves millions of people everyday, 60+ million photos added each week, 3+ billion photos served to users every day, and 100, 000+ images served per second during peak periods.

So you tell me, with such heavy traffic and usage, Facebook definitely has to invest in datacenters with their own caching and CDN right? That’s right!

Getting Started

Just register a Facebook account to manage all your photos and video contents. Upload your photos and videos onto Facebook albums, to get the CDN link,

  1. Access your album
  2. Click on the image
  3. At the bottom right of the image, copy the link from the download link provided.

An example of a Facebook CDN url might be something like this

Of course there are many CDN links that Facebook use. Facebook does have a CDN domain,


This is simple! In your website, just link the Facebook CDN link in, and you are all set to go!

That’s it, it’s that simple! You will notice that your site’s page load will be slightly faster. Of course, by using Facebook CDN, it doesn’t exactly reduce your site’s loading time too much because there are other factors prior to having a full CDN in place. For instance, both static or dynamic contents will be cached on these CDN Edge Servers. Files like your Javascript (.js), CSS(.css), PHP (.php), etc.

For those running on WordPress on your hosting server, you can always try out W3 Total Cache and it’s FREE. It’s a pretty decent cache plugin that caches your contents on your server, so users pulling the same content will be able to receive these cache content faster. There is also a CDN setting within this plugin which allows you to use premium CDN services to manage your site cache on their servers.

In conclusion, this setup isn’t exactly making use the full potential of a CDN service, however it does give you an idea of how it actually works and how you should leverage CDN on your websites!

That’s all folks! Have fun!

Every Singaporean Son

The journey in becoming Every Singaporean Son

Published Sep 10, 2011 in journal