How to Speed up your Drupal site: CDN integration using KeyCDN

| Drupal Development | 4 seen

In today's Drupal development series I will show how easy you can setup a true CDN for your Drupal site using third party CDN provider -  KeyCDN

Get a free $10 bonus by signing up for KeyCDN

About Content delivery network

content delivery network or content distribution network (CDN) is a globally distributed network of proxy servers deployed in multiple data centers. The goal of a CDN is to serve content to end-users with high availability and high performance. CDNs serve a large fraction of the Internet content today, including web objects (text, graphics and scripts), downloadable objects (media files, software, documents), applications (e-commerce, portals), live streaming media, on-demand streaming media, and social networks.

About KeyCDN

KeyCDN is a high-performance Content Delivery Network (CDN) and is one of the most affordable content delivery service on the market. With network spawning in Europe, Americas, Asia and Australia, with more networks planned KeyCDN seems has a very bright future in CDN market.

KeyCDN points of presence (existing and planed)

KeyCDN points of presence (existing and planed) 

It would be super cool to see a presence in Republic of Georgia, but they are at least in neighboring Turkey, so probably next time I will get more than 7,000 users visiting my blog from Turkey I will be better prepared (thus, I cant complain that I wasn't prepared good enough last time)

KeyCDN Pricing

I Signed up for a free 30 day trial account on KeyCDN, and now looking on their pricing I guess I will give this CDN company couple of months to test how great they really are.

KeyCDN pricing plans

KeyCDN pricing plans

I checked my Linode VPS graphs for last January, In total I had a traffic of about 120GB in January, which scaled to KeyCDN would make my monthly payment about $4.8. It's ridiculously cheap for CDN. I guess I can fine tune things on my blog, by compressing image sizes and get overall monthly traffic bellow $4 per month, which is not a big deal, but what actually would be a big deal - to reduce load sizes from my server, making site load even faster. 

Create a new zone on KeyCDN

Once you have signed up for KeyCDN, login and from dashboard choose Zones, click on New Zone button and enter your details

KeyCDN General zone settings

KeyCDN General zone settings

Give it a nice name, leave the default value Pull for Zone type (you could choose Push, but for the ease of this tutorial let's stick with Pull) and enter your websites url including http.

Zone URL

Zone URL

Installing CDN module for Drupal

Download this great module (CDN) from Drupal and enable it on your site. Now go to the Details tab on modules configuration page check next to the Origin Pull and enter your KeyCDN Zone URL 

Drupal CDN settings

Drupal CDN settings

That's it, basically you are done. Make sure you set your CDN to enabled and test how does it actually work!

Custom CNAME

A great feature you can do on KeyCDN is to use your own CNAME, instead of using http://mydomain.kxcdn.com I prefer using http://cdn,mydomain.com

Go to KeyCDN, from Zone alias, create new:

KeyCDN add Zonealias

KeyCDN add Zonealias

Now, you should create actual CNAME record on your DNS server. Here is how to create CNAME record for KeyCDN on Linode:

  • From DNS manager tab select your domain name
  • Scroll down until CNAME records
  • Click on Add a new CNAME record

Editing CNAME records on Linode

Editing CNAME records on Linode

It will take about 30 minutes for Linode to update your DNS, after then you can start using your custom CNAME

​CDN and SEO

One thing what makes me worried when dealing with CDN's is a possible duplicate content penalty from Google, luckily there are some steps we can do to prevent this to happen.

Go back to KeyCDN, click edit on Zone you created a while ago, and click on Show advanced Features

  • Make sure Canonical headers are enabled

Canonical header

  • Robots.txt enabled - Block crawlers from indexing the content in your zone.
  • Custom Robotx.txt

Copy following to custom robots.txt file 

User-agent: *
Disallow: /

KeyCDN Advanced Features

KeyCDN Advanced Features

HTTPS secure pages and KeyCDN

Not a problem, see this article Linode: How To Secure Nginx with Let's Encrypt on Ubuntu 12.04

The Bonus content

Get a free $10 bonus by signing up for KeyCDN with this link

Add new comment