If you know Response.Flush and Response.Clear, then you don't have to wait like this. Every time an Html page is generated, Response.write is used to immediately return a message indicating that the database record has generated Html. When a programmer writes a static page HTML generated from an ASP page, if a large number of pages are generated at the same time, he must have encountered a long waiting process with the progress bar below the browser showing 3%, 6%, 10%, etc. that slowly increases. . During this waiting process, you don't know which record has been generated on the page, so you can only wait with your eyes wide open.
If you know Response.Flush and Response.Clear, then you don't have to wait like this. Every time an Html page is generated, Response.write is used to immediately return a message indicating that the database record has generated Html.
In this way, when a large number of pages are generated at the same time, you are no longer alone looking at a blank page but just a slowly changing progress bar at the bottom of the browser. You can always know which database record has been generated. Even if there is an accident, such as a crash, power outage, etc., you will know the date on which the next generation should be recorded and restarted to generate HTML. Isn't it great? This is a progress bar and it is more specific.
Haha, don’t worry, let’s look at the meaning of Response.Flush and Response.Clear first.
The Flush method of the Response object immediately sends the output in the buffer. This method will cause a run-time error if Response.Buffer is not set to TRUE. Syntax: Response.Flush; Note: If the Flush method is called on an ASP page, the server will respond to the keep-alive request on the page. Applied to Response objects.
Regarding Buffer, here is an introduction. Buffer literally translates from English as buffer zone. Here we call it buffer because it is not only a noun, but also a verb.
The buffer is a place where a series of data is stored. The data obtained by the client can be output directly from the execution result of the program or output from the buffer. But there is a difference in speed between these two methods: in the web, when an ASP program is not requested many times, there is basically no difference between the two, at least we can't feel it. But when many people request an asp program, the speed is different. If there is no buffer, then the result obtained by each client who requests the ASP program is the result obtained by executing the ASP program once. If the ASP program is buffered in advance, the result obtained by each client is the buffered result. The result of the area is not the result of executing the program once. For example, 1,000 users access an ASP page at the same time. If the ASP program is not buffered, the program will be executed a thousand times, which will increase the load on the server and cause the client to open the page slower; if the ASP program is buffered, then the result will be different. Each client obtains data directly from the buffer, and the server will not increase the number of program executions due to increased access, so the speed at which the client opens the page will be slower than in the previous case. quick. This is the benefit of Buffer.
Regarding Response.clear, the Clear method deletes all HTML output in the buffer. But the Clear method only deletes the response body and not the response headers. You can use this method to handle error conditions. Note that this method will cause a runtime error if Response.Buffer is not set to TRUE. Syntax: Response.Clear; applied to Response objects.
Well, if you want to achieve the effect of immediate output, just add Response.Flush and Response.Clear after the desired output prompt information in the loop body. like:
<%
for i=1 to 2000
for i1=1 to 3000
''Empty loop, extending each execution time
next
Response.write i&)
Response.Flush
Response.Clear
next
%>
After you execute the above asp statement, you will find that the output is output one by one. If you execute it once, it will be output once.
But I saw someone on the Internet saying that many times, we find that even if we use Response.Flush(), the previous information is not sent to the client for display. We are still presented with a white screen. After repeated testing, I came to a conclusion: the flush content must be at least 256 bytes. That is, only if the compilation generates at least 256 bytes of data, the information can be sent to the client and displayed after executing Response.Flush().
It's strange that the statement I gave above indeed achieves the effect of displaying one by one, and does not output 256 bytes in advance. You can save the above statement as Notepad and run it to see, the effect is displayed line by line. The opinions listed by me only represent flymorn’s personal opinions and may not be used for other purposes.
If you really need to output 256 bytes beforehand, you can do this:
<%
dim liji
for i=1 to 256
liji=liji&<!--First generate 256 characters-WWW.PIAOYI.ORG-->
if len(liji)>=256 then exit for
next
%>
If you have different views or different test results, please feel free to discuss it with me.