We all know that a CDN helps to decrease a blog’s load time, but the problem is that most CDN services cost money.
Here at ShoutMeLoud, we’ve already shared a post on how to boost your blog’s performance with Rackspace cloud files, but again you need to pay for a Rackspace account.
Well now, I’m sharing with you a tutorial on how you can use your free Dropbox account as a CDN using the Super Cache WordPress plugin.
You will be surprised to know that Dropbox lowered my site’s load time by 4x.
My site took around 6.1 seconds to load, but after using Dropbox, the load time lowered to just 1.5 seconds.
- That’s exactly 4.06x lower.
Some other advantages of using Dropbox as a CDN:
- It’s free.
- It lowers down the site’s bandwidth.
Look at the screenshot below in which you can see how much faster Dropbox loads vs. other CDN servers.
How to Use Dropbox as a CDN
First, download all of your site’s static files (i.e. wp-content and wp-includes folders in WordPress).
Next, upload all of these files to Dropbox and link to them from your site.
Linking these is a pretty lengthy task, so that’s where the WP Super Cache plugin comes in. (If you don’t have it, download WP Super Cache from here and install it.)
1. Download the COMPLETE wp-content and wp-includes folders (you can skip .php files) from WordPress.
2. Create a new directory (let’s call it “CDN”) in your Dropbox public folder.
- If you don’t have a Dropbox account, you can sign up here.
3. Create a new sub-domain (e.g. cdn.example.com).
- (Scroll down to learn why you should create a sub-domain and what to do if you don’t want to create one.)
4. Open your site’s file manager and in the directory “CDN”, create a new file named .htaccess and add the following code: (Replace “ID” with your Dropbox ID)
Redirect 301 / http://dl.dropbox.com/u/ID/cdn/
5. Open the Super Cache settings page and click on the “CDN” tab. Configure the settings accordingly. (Replace cdn.havefunforever.com with the URL to the sub-domain you created in the 3rd step.)
6. Click on “Save” and that’s it. Everything is done.
Why a Sub-Domain? I don’t want to create a sub-domain!
Well, the sub-domain thing is optional, but I prefer to use it because it keeps URLs clean and is also better for branding.
If you are sure you don’t want to create a sub-domain, then you can:
- Skip the 3rd and 4th steps.
- In the Super Cache CDN settings page, in Off-site URL, give the path to your Dropbox folder where all of the files reside (http://dl.dropbox.com/u/ID/cdn).
From now on, all of your files will be hosted on Dropbox, so whenever you change anything in the wp-content and wp-includes folders (except changes in .php files), you must also apply the changes to the files hosted on Dropbox.
If you upload any image to your WordPress site, you must also upload the image to Dropbox.
Do let us know if you have any queries while setting up Dropbox as a CDN. Also if you have set up this free CDN for your WordPress blog, don’t forget to check your blog’s load time and let us know the difference in the comments below.