DNS Prefetching

Published on Jul 28, 2014
Increasing page load speed is essential to get users to your content quickly. For the past few months I have been utilizing compression tools for my JavaScripts and CSS files, but I know that this only goes so far. In a way to make my pages load faster I opted to move all my images to a different server and thus set up a private CDN (Content Delivery Network) for this site. If you have an image intensive site then this is a great way to load static assets quickly, because CDN are load-balanced and configured to serve content as close to your user as possible. So instead of loading an image from a server in say, New York, my CDN actually is smart enough to know that my user may be loading pages from Germany and will call the appropriate server. Plus these types of solutions are relatively cheap additions to your site. As I dug deeper into the enigma of page load times and how that effected SEO (a fun tidbit, slow pages get bumped down in Google Searches) I stumbled upon DNS prefetching. No, this is not a dog thing. Rather it is actually a nice little tag that suggests to the browser that they should look up a domain as soon as it is convenient. So instead of doing the lookup for each image that the browser requests it does one lookup and loads the image. Thus increasing your page load speed. Booyah! As a good example, this site uses two locations for fonts and sharing tools ([Google Fonts](https://www.google.com/fonts) and [ShareThis](http://www.sharethis.com)). Both of these URLs are somewhere else, not here, and thus when the request is made the browser stops and does a lookup for the domain. Since this can slow the page load this nifty little tag requests the browser to lookup before are even requested. Ideally, you don’t need to do this for all your domains, but I generally use it for the ones that I hit frequently or will be getting a lot of requests. Any questions? I definitely am interested in carrying this conversation further since I haven’t seen whole lot of drawbacks to doing this other than the amount of DNS prefetches that you can do.
Justin Hough author picture
Justin Hough

Chief Development Officer at Hounder. He is a Christian, husband, father, writer, developer, designer, and a digital carpenter crafting amazing web experience. Also, created the Centurion Framework many moons ago.