| .NET DotNet Forum Index » VB.NET Forum (Visual Basic .NET) » WebRequest - What Happens When ?... |
|
Page 1 of 1 |
|
| Author |
Message |
| eBob.com... |
Posted: Wed Oct 28, 2009 7:30 pm |
|
|
|
Guest
|
I thought I might save some time in a web application by caching some files
which are not likely to change very often. But I am wondering when the file
is actually fetched. Does anyone know when the bytes of the file are
actually transmitted in the sequence of statements below?
1) Dim URL As String = "http://path.jpg"
2) wrq = WebRequest.Create(URL)
3) wrp = DirectCast(wrq.GetResponse(), HttpWebResponse)
4) MsgBox("LastModified: " & wrp.LastModified)
5) MsgBox("ContentLength: " & wrp.ContentLength)
6) Dim sr As New StreamReader(wrp.GetResponseStream,
Encoding.GetEncoding(1252))
7) FileBytes = sr.ReadToEnd()
There's no point in keeping a cache if the bytes are actually transmitted
during the execution of line 3.
Thanks, Bob |
|
|
| Back to top |
|
|
|
| Fred... |
Posted: Thu Oct 29, 2009 4:55 am |
|
|
|
Guest
|
in news:%23Fw1WdDWKHA.4816 at (no spam) TK2MSFTNGP06.phx.gbl, eBob.com wrote :
Quote: I thought I might save some time in a web application by caching some
files which are not likely to change very often. But I am wondering
when the file is actually fetched. Does anyone know when the bytes
of the file are actually transmitted in the sequence of statements
below?
1) Dim URL As String = "http://path.jpg"
2) wrq = WebRequest.Create(URL)
3) wrp = DirectCast(wrq.GetResponse(), HttpWebResponse)
4) MsgBox("LastModified: " & wrp.LastModified)
5) MsgBox("ContentLength: " & wrp.ContentLength)
6) Dim sr As New StreamReader(wrp.GetResponseStream,
Encoding.GetEncoding(1252))
7) FileBytes = sr.ReadToEnd()
There's no point in keeping a cache if the bytes are actually
transmitted during the execution of line 3.
Perhaps have a look at Method property (user HEAD)
--
Fred
foleide at (no spam) free.fr |
|
|
| Back to top |
|
|
|
| AMercer... |
Posted: Thu Oct 29, 2009 1:10 pm |
|
|
|
Guest
|
In some old code of mine that looks like yours, I have a comment that
GetResponse (ie your line 3) may block a noticeable amount of time. My
recollection is that none of the other statements take any significant amount
of time. Now maybe that is enough for your concerns, or maybe not. I went
to the documentation and was exasperated by the lack of clear language. So,
while I don't really know the specific answer to your question, maybe knowing
where your thread will block is enough for your purposes.
"eBob.com" wrote:
Quote: I thought I might save some time in a web application by caching some files
which are not likely to change very often. But I am wondering when the file
is actually fetched. Does anyone know when the bytes of the file are
actually transmitted in the sequence of statements below?
1) Dim URL As String = "http://path.jpg"
2) wrq = WebRequest.Create(URL)
3) wrp = DirectCast(wrq.GetResponse(), HttpWebResponse)
4) MsgBox("LastModified: " & wrp.LastModified)
5) MsgBox("ContentLength: " & wrp.ContentLength)
6) Dim sr As New StreamReader(wrp.GetResponseStream,
Encoding.GetEncoding(1252))
7) FileBytes = sr.ReadToEnd()
There's no point in keeping a cache if the bytes are actually transmitted
during the execution of line 3.
Thanks, Bob
.
|
|
|
| Back to top |
|
|
|
|