Making your site faster

If your pages use a lot of resources such as images, then perhaps it would be wise to prefetch those resources so your page loads faster. DNS prefetching would be a way to do that.

DNS prefetching

DNS prefetching informs the browser of resources on other domain names that are referred to within the page early on during the page load, so it can do the DNS resolution of these domain names.

A browser has to look up a domain name on a Domain Name Server (DNS) to figure out where it is located on the Internet. Sometimes, it has to go through multiple layers of Domain Name Servers and it could be very slow and is not always consistent. By using DNS prefetching, even before a user clicks a link, or loads a resource, the DNS resolution for that particular domain name is done and the resource can be fetched much faster.

Google states that this saves about 200 milliseconds on a resource hosted on an external domain name.

If you host your assets on a Content Delivery Network (CDN) like Amazon's S3 or even if you refer to Google's API or Microsoft's API CDN, it would be faster to get these files when they are prefetched.

DNS prefetching is invoked by writing the following code within the head tag of a HTML file:

<link rel="dns-prefetch" href="//image.cdn.url.example.com">

Browsers that understand prefetching would immediately start attempting to resolve the DNS for the link within the href attribute. The following is how it would look for Amazon S3:

<link rel="dns-prefetch" href="//s3.amazonaws.com">

Currently, Firefox 3.5 and higher, Safari 5 and higher, and IE9 and higher, support DNS prefetching.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset