473,662 Members | 2,413 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

GetResponse delay

I do some peeking at files on the web in my program with code such as:

WebRequest wr = WebRequest.Crea te(url);
WebResponse r = wr.GetResponse( );

I've noticed that the first time GetResponse is executed, it takes some 3 to
4 seconds. Repeating the same code in the same run is almost immediate. So
why the delay the first time this is executed on each run? And can I do
anything about it?
Mar 6 '06 #1
4 1747
"JezB" <je***********@ blueyonder.co.u k> wrote in message
news:ek******** ******@TK2MSFTN GP11.phx.gbl...
I do some peeking at files on the web in my program with code such as:

WebRequest wr = WebRequest.Crea te(url);
WebResponse r = wr.GetResponse( );

I've noticed that the first time GetResponse is executed, it takes some 3
to 4 seconds. Repeating the same code in the same run is almost immediate.
So why the delay the first time this is executed on each run? And can I do
anything about it?


This is a very normal thing for PCs. Haven't you ever used a PC before and
noticed that doing practically *anything* takes longer the first time?

Michael
Mar 6 '06 #2
I've been using PCs for 20 years pal. Doesn't explain why the same url in a
web browser appears instantly (it's only a small text file) yet GetResponse
takes 4 seconds - there must be a reason for it, and I assume you don't know
it.

"Michael C" <no****@nospam. com> wrote in message
news:uZ******** *****@TK2MSFTNG P15.phx.gbl...
"JezB" <je***********@ blueyonder.co.u k> wrote in message
news:ek******** ******@TK2MSFTN GP11.phx.gbl...
I do some peeking at files on the web in my program with code such as:

WebRequest wr = WebRequest.Crea te(url);
WebResponse r = wr.GetResponse( );

I've noticed that the first time GetResponse is executed, it takes some 3
to 4 seconds. Repeating the same code in the same run is almost
immediate. So why the delay the first time this is executed on each run?
And can I do anything about it?


This is a very normal thing for PCs. Haven't you ever used a PC before and
noticed that doing practically *anything* takes longer the first time?

Michael

Mar 6 '06 #3
"JezB" <je***********@ blueyonder.co.u k> wrote in message
news:e8******** ******@tk2msftn gp13.phx.gbl...
"Michael C" <no****@nospam. com> wrote in message
news:uZ******** *****@TK2MSFTNG P15.phx.gbl...
"JezB" <je***********@ blueyonder.co.u k> wrote in message
news:ek******** ******@TK2MSFTN GP11.phx.gbl...
I do some peeking at files on the web in my program with code such as:

WebRequest wr = WebRequest.Crea te(url);
WebResponse r = wr.GetResponse( );

I've noticed that the first time GetResponse is executed, it takes some 3 to 4 seconds. Repeating the same code in the same run is almost
immediate. So why the delay the first time this is executed on each run? And can I do anything about it?
This is a very normal thing for PCs. Haven't you ever used a PC before and noticed that doing practically *anything* takes longer the first time?

Michael

I've been using PCs for 20 years pal. Doesn't explain why the same url in

a web browser appears instantly (it's only a small text file) yet GetResponse takes 4 seconds - there must be a reason for it, and I assume you don't know it.


I see to possibilities.

1) There is a high overhead setting up the HTTP connection and the second
time its reused...
2) The immediate code is compiled the first time and the second time its
already present. That might be a side-effect of dotNET.
3) A round-trip to the server is expensive and the second time the cache is
used (not too likely that this is the case).

Of course combinations are possible too...

- Joris
Mar 6 '06 #4
"JezB" <je***********@ blueyonder.co.u k> wrote in message
news:e8******** ******@tk2msftn gp13.phx.gbl...
I've been using PCs for 20 years pal. Doesn't explain why the same url in
a web browser appears instantly (it's only a small text file) yet
GetResponse takes 4 seconds - there must be a reason for it, and I assume
you don't know it.


It's called cache my friend.

Michael
Mar 6 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
18823
by: Des L. Davis | last post by:
System: Dell PowerEdge Server with 3 GB RAM, 2.4 GHz Celeron Software: Microsoft SQL Server 2000 Enterprise running on Windows 2003 Server Software: Microsoft SQL Server 2000 Enterprise running on Windows 2000 Server If you run the code below, you'll notice something odd occuring. The MilliSecond value does not change after a 1Millisecond delay. Is this a bug or am I doing something wrong? Any assistance will be greatly appreciated
6
6141
by: Jonathan | last post by:
Calling the System.Net.WebResponse.GetResponse method (see code below) results in the following error: System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive. at(System.Net.HttpWebRequest.CheckFinalStatus()) at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult) at(System.Net.HttpWebRequest.GetResponse())
6
5552
by: lucifer | last post by:
hi i need to insert delay in my program what function should i use the old delay is not supported by the VC6
5
35973
by: Nathan | last post by:
This is a copy of a message at microsoft.public.dotnet.framework.clr: THE CODE: I'm using an HttpWebResponse object to send an HTTP POST to a Java server I have written and are running on the same machine (for dev and testing). Here is the C# code snippet: 1 string clientAddr = "http://127.0.0.1:22225/"; 2 try 3 { 4 webreq = (HttpWebRequest)WebRequest.Create( clientAddr );
1
12586
by: Jeff B | last post by:
I'm trying to create a simple screen scraping application and I kept getting a System.Net.WebException thrown back with a message of "The operation has timed-out." At first I thought it was some kind of connectivity issue on the machine. It didn't make sense though, because I can open up a browser on the same machine and easily browse the web. I'm stumped. I looked over my code for any errors and just couldn't find what I was doing...
8
13563
by: Morgan Cheng | last post by:
I happens to surf to http://www.codeproject.com/cs/internet/Crawler.asp, which claims that WebRequest.GetResponse() will block other thread calling this function until WebResponse.Close() is called. I did some experimentation. public static void Main(string args) { for (int idx=0; idx<10; ++idx)
5
4868
by: mr.newsgroupguy | last post by:
I am working in C# .NET 1.1. My app has a button on its main form that checks to see if it has access to a file on our server, just an XML file. On our server we are running W2K IIS with a virtual directory, set to Windows Authentication. I am creating an HTTPWebRequest object on the client, and setting its Credentials to CredentialCache.DefaultCredentials. Also, I have tried numerous Timeout settings, but they have not made a...
4
5193
by: =?Utf-8?B?SmltIE93ZW4=?= | last post by:
Hi, I've run into a set of errors I don't understand coming back from HttpWebRequest.GetResponse, In one case, null is returned from the request without an Exception and in the other the request does not appear to leave my system yet still returns the 500 error. In the code below, there is a xml-snippet that I use as a test. When I run the test using the snippet, the server on the other side logs and processes the request correctly...
0
8343
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8762
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8633
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7365
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4179
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4347
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2762
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1992
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1747
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.