Use Response.Buffer=True to speed up the program. The content of Response.Flush() must be at least 256 bytes.
for i=1 to 256
yongfa365=yongfa365&<!--The main purpose here is to let the front generate 256 characters first, so that it can be output in real time-->
if len(yongfa365)>=256 then exit for
next
MadeBasic()
MadeModel()
MadeIndexBlogItem()
response.Write 1/6 All templates are generated<br>&yongfa365
Response.Flush()
MadeIndex(Calendar)
response.Write 2/6Date index generation completed<br>
Response.Flush()
MadeIndex(Category)
response.Write 3/6 Classification index generation completed<br>
Response.Flush()
MadeIndex(Blog)
response.Write 4/6 Total index generation completed<br>
Response.Flush()
MadeRSS()
response.Write 5/6 RSS generation completed<br>
Response.Flush()
MadeItem(all)
response.Write 6/6 All articles are generated <font color=red>OK, finally completed</red>
Response.Flush()
The above is a piece of code that dynamically generates a static file in the background. The purpose is to allow you to see where the program is executing. Before I didn't add Response.Flush(), I just looked at the progress bar in the IE status bar. It felt so depressing. Adding Response After .Flush(), I feel so good. Here is a collection of some reference materials found on the Internet:
I don’t know how much everyone knows about Buffer. Many people are vague about this concept, especially in ASP. Many beginners rarely use this statement when writing asp programs. Let me talk about the purpose of Buffer and its role in asp programs.
1. Buffer
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.
2. How to buffer the asp program
This problem is actually very simple. Just add: in the first line of the asp program:
<% Response.Buffer = True %>
That's it.
The meaning of this sentence is to indicate whether the output page is buffered. When the attribute value is True, the server will not send any information to the client until all programs are executed or encounter
<% Response.Flush %> or <% Response.End %>
statement to release the buffer information.
Using Response.Buffer=True and Response.Flush can increase the browsing speed. If a page has Response.Buffer=False, there are 30 data transfers. If 100 people browse this page, there are 3000 A round-trip transmission seriously affects efficiency; if you set Response.Buffer=True at the beginning, divide the entire page into several groups, and use Response.Flush in appropriate places, the visitor's experience can be greatly improved.
3. Why sometimes I feel useless
for example:
<%
'Warning: Don't run this if you have nothing to do
for i=1 to 10000
Response.Write <b><center><font color=#FF0000>I am www.yongfa365.com&i&</font></center></b>
Response.Flush
response.Clear
next
%>
It will take a long time to come out, and a bunch of them will come out, and then they will come out one by one.
reason:
Response.Flush(). He will first send the compiled data in the buffer to the client
but
The content of flush 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().
Clear method
The Clear method deletes all HTML output in the buffer. The Clear method only deletes the response body but not the response headers
grammar
Response.Clear
Comment
Calling Response.Clear will clear the data output in the previous part of this page. At the same time, if the program sets Response.ContentEncoding, Response.Clear will also set the encoding method to direct transmission.
Applies to Response object
4. Summary
Although the Buffer attribute of Response can improve the page display speed, it depends on the situation. If you are making an ordinary personal homepage, the number of visits is not very high, and there are no complex execution programs, then it is not very important whether to use this attribute, because it takes a while to buffer the data, but we can’t feel it. ; But if you are making a large forum or a product display or other business site, and the traffic is very high, then I recommend adding the sentence <% Response.Buffer = True %> to the first line of the program, because this It allows customers to obtain more data in an effective time.
Attached:
Generally, there is this in the file header of the verification code.
Response.Buffer=false
Response.Expires=0
Response.ExpiresAbsolute = Now() - 1
Response.AddHeader Pragma,No-Cache
Response.AddHeader Cache-Control,Private
Response.CacheControl = No-Cache
Just to prevent it from being cached.