Response.flush()

J

Jon Spivey

Experimenting with response.flush() but can't seem to get it to work. This
code
<%
response.write "<p>started</p>"
response.flush()
for i = 1 to 10000000
i = i +1
next
response.write "<p>ended</p>"
%>
Should it not write started to the screen straight away and then a couple of
seconds later, when the loops finished, write ended? When I test on XP Pro
and Windows Server 2003 the flush doesnt happen - the page takes a couple of
seconds to load up and then writes started ended at the same time.

Also found this article on aspfaq
http://www.aspfaq.com/show.asp?id=2498
but the response.flush() doesn't happen with that sample code either

Any ideas?

Jon
 
R

Ray at

I believe there's a thing about certain browsers, i.e. IE, where they won't
display anything until the response they've received is of a minumum number
of bytes. I don't know what the minimum is, though. You could try adding a
line like so above the <p>started</p> line:

response.write "<!-- " & String(200, "x") & " -->"

BTW, do you know that your for-loop is essentially doing a Step 2? You
don't have to increment the looping variable.

Ray at work
 
J

Jon Spivey

Hi,
thanks for the reply I tried adding some more text to my little sample and
guess what - the flush happened on my dev machine XP Pro/IIS5.1 but not my
web server IIS6/Windows Server 2003. My problem is I'm working on this site
www.bookhead.co.uk if you click any of the book links the next page pulls
the book details from sql server 2000 then uses xmlhttp to get prices for
the book from 11 retailers. The db lookup is quick, the xmlhttp part can
take about 10 seconds - so I put response.flush() after the db lookup, the
flush isn't happening with the result that the page takes about 10 seconds
to display - obviously unacceptable so I need to fix this

I can't post up the code for the page I'm working on its ~150 lines is there
something you can think of that would stop response.flush() from happening?
I've also written my host to see if they have any ideas

Jon
 
S

Sylvain Lafontaine

Your code work perfectly well on my XP Pro workstation, with the web server
being on the same machine.

Maybe you are separated from you Windows Server with a firewall or a proxy
who is buffering the whole thing. Your LAN may also be involved.

I suggest that you install the web server directly on you station and then
making somes tests with that configuration.

S. L.
 
R

Ray at

I've run into this problem before and I've yet to find a definitive answer.
I believe that it's a browser issue, actually. When I loaded your code on
my W2K server, it did not [seem to] flush just as you described. Then I
added the long comment and it worked. Then I restored the code back to
exactly what you posted and it flushed that time. Inconsistencies do not
make sense. I believe that if you quickly do a view-source while you're
waiting for your flush, you may actually see the <p>started</p> in there.

Ray at work
 
J

Jon Spivey

I'm working on my laptop at the moment IIS on the same machine - no lan
firewall proxy etc. The real issue here is the site I'm working on that I
posted up earlier - not being able to get response.flush working is ruining
the site.

Just for the heck of it I uploaded Ray's code with the long string here
http://www.roksteady.net/flushed.asp

The flush works on my dev machine but is not happening on the web server -
running IIS6 Windows Server 2003. Also tested in Netscape 7 and firebird
just to be sure it isn't an IE thing. I wonder if response.flush() is
somewhat flakey or there is something I'm missing here. Either way I need to
get to the bottom of this

Jon
 
J

Jon Spivey

As far as I can see this must be a server issue - from my testing the exact
same pages that refuse to flush on my IIS6 web server flush perfectly on 2
IIS5.1 computers here. Still trying to get to the bottom of this but running
out of ideas.....

Jon

Ray at said:
I've run into this problem before and I've yet to find a definitive answer.
I believe that it's a browser issue, actually. When I loaded your code on
my W2K server, it did not [seem to] flush just as you described. Then I
added the long comment and it worked. Then I restored the code back to
exactly what you posted and it flushed that time. Inconsistencies do not
make sense. I believe that if you quickly do a view-source while you're
waiting for your flush, you may actually see the <p>started</p> in there.

Ray at work

Jon Spivey said:
Hi,
thanks for the reply I tried adding some more text to my little sample and
guess what - the flush happened on my dev machine XP Pro/IIS5.1 but not my
web server IIS6/Windows Server 2003. My problem is I'm working on this site
www.bookhead.co.uk if you click any of the book links the next page pulls
the book details from sql server 2000 then uses xmlhttp to get prices for
the book from 11 retailers. The db lookup is quick, the xmlhttp part can
take about 10 seconds - so I put response.flush() after the db lookup, the
flush isn't happening with the result that the page takes about 10 seconds
to display - obviously unacceptable so I need to fix this

I can't post up the code for the page I'm working on its ~150 lines is there
something you can think of that would stop response.flush() from happening?
I've also written my host to see if they have any ideas

Jon

adding work.
This XP
Pro
 
J

Jon Spivey

Did some more searching and found the answer - it seems IIS6 has some
performance issues with response.flush with a fix due in the first SP
http://groups.google.com/groups?hl=...q=response.flush+iis6&ie=UTF-8&oe=UTF-8&hl=en

Solved my own issue with a very nasty hack
do db lookup then stop
javascript to redirect to the same page
finish processing page
This accomplishes almost the same thing as response.flush() but we shouldn't
have to do things like this on supposedly "better" products

Jon

Jon Spivey said:
As far as I can see this must be a server issue - from my testing the exact
same pages that refuse to flush on my IIS6 web server flush perfectly on 2
IIS5.1 computers here. Still trying to get to the bottom of this but running
out of ideas.....

Jon

Ray at said:
I've run into this problem before and I've yet to find a definitive answer.
I believe that it's a browser issue, actually. When I loaded your code on
my W2K server, it did not [seem to] flush just as you described. Then I
added the long comment and it worked. Then I restored the code back to
exactly what you posted and it flushed that time. Inconsistencies do not
make sense. I believe that if you quickly do a view-source while you're
waiting for your flush, you may actually see the <p>started</p> in there.

Ray at work

Jon Spivey said:
Hi,
thanks for the reply I tried adding some more text to my little sample and
guess what - the flush happened on my dev machine XP Pro/IIS5.1 but
not
my lookup,
the
on
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top