Supercharge your website performance using CDN + 3rd party DNS + Caching
Lets face it no one likes a slow website, it frustrates your visitors and makes them much less likely to stick around. But one of the best reasons for having a blazing fast site is Google will rank your content more favorably which means more visitors/customers to start off with, Yay!
If you would like to see how your existing website performs punch in your URL into http://tools.pingdom.com/fpt/. It will analyze the page for bottlenecks and make recommendations on how to correct these.
I recently did this for our own website and aimed for 100/100 website performance grade and made it! I have listed the key elements below in achieving a perfect performance score below.
Step 1: DNS Servers
Visitors need to get to your server… and FAST! If you’re using a cheaper host you are most likely using their budget DNS servers as well which reside in a single location. Ideally you want a DNS provider who has anycast servers placed all over the world. By implementing this it will speed up the DNS queries so people can get to your webserver faster. Check out DNS Made Easy, I have been using them for a while now and are outstanding!
Step 2: Use a CDN for your static content
Serving your scripts/images/video/css files from a Content Delivery Network (CDN) is a great performance boost as the files are delivered from the closest possible location to your visitor. For example if the user is in Europe and your webserver is based in Australia the images/scripts will be delivered to the user from a server in Europe which dramatically speeds things up.
Another huge benefit is that it allows you to parallelise downloads across hostnames as your webserver will only allow a certain amount of connections, but this is then doubled (or more) if you spread the content out over multiple locations, i.e., it will download more files at the same time.
This will also greatly reduce the load on your server as generally the main bottleneck is bandwidth. By moving the bulk of the larger files away from your primary server it can reduce you bandwidth requirements by 90+% if implemented well.
There are several providers for this. Amazon Cloudfront is my preferred choice.
Step 3: Caching and Compression
Caching is great especially again for static content. At a minimum I’d recommend caching static files such as images, videos etc. There are many ways to setup caching but below are a few quick tricks for a linux based server.
.htaccess Header set Cache-Control for images, scripts etc:
As most of this content just about never changes it’s not a silly idea to enable caching for it. Simply create an .htaccess file with the below and save it into the root of your website:
The above sets the caching period of 7 days (604800 seconds) for any of those files types.
If you have used Amazon CDN or S3 buckets for your static files you can also set this on each object by logging into your AWS panel, find the file / object you want to cache. Then click on the Properties Tab >> Metadata. Then add another key called Cache-Control and set the value to: max-age=604800, public
This can be added via the .htaccess file as well. Simply add the below lines to the file (add any other extensions you might need)
Once you have implemented the steps above run your site back through Pingdom to see what your new performance grade is. Naturally every site is going to be different and have it’s own performance issues so keep checking out your Pingdom report and work through the performance grade recommendations to get that perfect score!