Your website’s performance or speed is one of the factors that decides your ranking in search engines, and a CDN plays a vital role here. Website that loads quickly also improves user experience and helps build loyal readership.
Improved site speed is also a good SEO practice. Google as well as Yahoo! suggest in their Performance Best Practices that serving static content from a cookieless domain or using a Content Delivery Network (CDN) helps. This reduces total size of the requests made for a page. In this article, I will explain you how to you implement this in 30 minutes flat.
Using a CDN for a small website or blog would be expensive. So is there a way we can set up our own CDN or a cookieless domain from which we can serve the static content? The answer is Yes! And I will describe the steps to achieve this.
What is Static Content?
What is CDN – The Definition
A content delivery network (CDN) is a collection of web servers geographically distributed across the globe. The server with the fewest network hops or the server with the quickest response time is chosen to deliver the content, thus improving response time. CDN is generally used to serve static content and does not set any cookies. Thus the request size is also reduced.
How to Create Your Own CDN or a Cookieless Domain?
Easiest way is to setup a CNAME record aliasing your static domain to your main domain. You will need register a separate domain name to do this or you can use a subdomain of your domain.
If you do not have a separate domain, create a subdomain using your site’s control panel. Make sure that the subdomain points to your main domain’s root folder.
Now that you have a domain or subdomain to serve static content, go to the DNS Zone Editor of your website’s control panel and create a CNAME record as shown.
Add the domain/subdomain you created earlier to the Name/Label/Alias of CNAME record. It should point to your main domain i.e. www.riyaz.net in this case.
If you are using a subdomain, you need to do one more step to make sure that no cookies get set on this subdomain. Two common cookie setters are WordPress and Google Analytics. Rob Flaherty has explained in easy steps how to prevent these sites from setting cookies on your CDN or static subdomain. The section ‘Separate domain or subdomain?’ explains how to get read of the cookies.
How to Serve Static Content from Your CDN?
http://www.riyaz.net/images/myimage.jpg will now become
But this could be a cumbersome task. How do I do this quickly? Simply use the W3 Total Cache plugin from W3-EDGE and enable CDN. Use Mirror as CDN Type.
Now go to CDN Settings of the plugin and set the Configuration parameters as shown below:
You may leave the other parameters to their defaults.
Thus you have setup your cookieless static content provider.
- Serving Static Content from a Cookieless Domain (Rob Flaherty)
- Use a CDN (Content Delivery Network) (Yahoo! Best Practices)
- Serve static content from a cookieless domain or CDN (Google Best Practices)