How to improve site speed - Part 2 - Network
Published 26th May 2011
The network is always the slowest part of viewing a web page. When developing a website locally, it is all too easy to include a lot of resources without realising the impact that it has on page load times.
For every resources that is required, the browser has to connect to the appropriate server and download the resource. If the browser has not seen the server before, the browser will also have to do a DNS lookup. DNS lookups and establishing a connection all take time. Doing it once is generally very quick (tens to hundreds of milliseconds). However if there are a lot of request to a lot of servers, this can all add up to a significant amount of time wasted.
According to the HTTP 1.1 specification, the maximum number of concurrent connections per host is two (although most modern browser increase this limit to four or six). Having too few connections can cause the download to stall, as the browser waits idly for the connections to be freed up. To get round this bottle-neck, serve media from several domains. This increases the amount of connections the browser will make to the website. This can speed up the delivery of resources, as the bottle-neck moves from number of connections to the server to the bandwidth of the connection. Experimental evidence suggests that the ideal number of media domains is currently three.
When you are serving media resources from their own domains, you do not need to send cookies with the request. This will speed up the time it takes to transfer the resources as you won't have to wait for the browser to send the sites cookie with each request. If your cookie is 500 bytes in size and you have 25 resources on your page, you can save 112.5 Kilobytes per page load.
Avoid bad requests (404) wherever possible. They are essentially wasted requests that stop the page from being loaded. The return value of 404 resources is never cached, just in case the resource is made available at a later date. This increases the amount of round trips to the server. 404 pages are also often quite large as they can be used to give the user a descriptive message. While this is a good idea for web pages that a user is likely to see, when it is a media resource it just wastes time and bandwidth.
3rd Party Resources
Resources that are hosted on 3rd party servers can also add to the total time and size downloaded for a web site. If the 3rd party component is slow, or down for some reason, this will impact the speed and usability of your website. For this reason, you should consider the value of the 3rd party components before you use them on your website. The P3PC project aims to score the impact of 3rd party components. It is worthwhile checking out if the component you want to use is scored there and what impact it will have on your website.
Speak to us
Mercurytide have the knowledge and experience to make your website work harder for you. Whether you are a small company wanting to take your first steps on the web or a more seasoned business wanting to raise your game to the next level, Mercurytide can not only help now but will keeping helping you at each step along the way.
To find out more on how to make the most of your website and to help your business grow, get in touch with Mercurytide.