I have a question regarding the performance of the .Net HttpWebRequest client (or WebClient, gives similar results).
If I use HttpWebRequest to request an html page (in this case news.bbc.co.uk) and analyse the speed (using HttpAnalyzer) at which the response is read by the application, this is significantly slower than a browser (Firefox, Chrome, IE) requesting the same resource (all caches cleared etc). The .Net application takes approximately 1.7 seconds versus 0.2 - 0.3 seconds for a browser.
Is this purely down to the speed and efficiency of the code / application or are there any other factors to consider?
Code as follows:
HttpWebRequest request = null;
Uri uriTest = new Uri("http://news.bbc.co.uk");
request = (HttpWebRequest)WebRequest.Create(uriTest);
request.Method = "GET";
request.KeepAlive = true;
request.Headers["Accept-Encoding"] = "gzip, deflate";
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
response.Close();