So whenever someone is talking about how fast your site is running or SEO (Search Engine Optimisation) you hear a lot about HTTP requests.
So what is HTTP?
Well lets start at the beginning. HTTP stands for Hyper Text Transfer Protocol and it’s how the internet works. You use it every time you browse the internet but you may not even be aware. Ever seen a website address that looks like this?
Of course you have, but did you see it? Did you see the HTTP? It’s right there at the start of the address. It’s the http:// bit and it tells the browser that it needs to visit the site www.smileyhappycoder.co.uk using the Hyper Text Transfer Protocol.
Ok, what’s a HTTP request?
In the above piece of code there are three HTTP requests to the server and that’s the most simple piece of code I could dream up. Now here comes the real problem. Browsers can only process so many requests at a time. This number ranges from 2 to 6 depending upon which browser you favour. So you could have a page that has say 20 HTTP requests and using the best browser you would be able to make 6 requests at a time. But that leaves 14 to go. So what happens? After the first 6 are done the next 6 start and so on until the page is fully loaded.
So what does this mean to you and your site?
Simply put the more requests, the longer the site will take to download. So now you see why largely image based sites may look the best but may not be best suited to your needs.
HTTP requests are a necessary evil, there is nothing that can be done to avoid them but there are ways to minimise them. For instance there is a school of thought that says you should have multiple CSS files each targeting a specific part of the design such as layout, typography and galleries. I can see the point here without a doubt, it makes the site easy to maintain but wait, that’s three requests not one. You could even use CSS Sprites for hover state images which will save yet more requests. The list is endless but this post is not…