How to Enhance ASP program performance (3)

Source: Internet
Author: User
Tip 11: Use response buffering
By opening "Response buffering" You can buffer an entire page content that is worth outputting, which minimizes the amount of data output to the browser, thereby improving overall performance. Each output consumes a lot, so the less you write, the better the effect. TCP/IP is more efficient at sending a small number of large packets than sending large numbers of packets, because it is slow to start and send continuously.
There are 2 ways to open response buffering. First, you can use Internet Services Manager to open response buffering for the entire application, which is the recommended way, and in IIS4.0 and IIS5.0, the response buffering is turned on by default. Second, on each page, you can put the following code on the head to open response buffering:
<% Response.Buffer = True% >
This code must be executed before any data is exported to the browser (that is, before any HTML content is displayed and before any cookies are set). In general, it is a good solution to open response buffering for the entire application, so that you do not have to set the code as above on each page header.
A common problem with opening response buffering is that the user must wait for the entire page to be fully produced before they can see the content. For a long running page, you can set the Response.buffer=false off buffer. Then, a good strategy is to take advantage of the Response.Flush method, which will output all HTML content that has been described by ASP to the browser. For example, after describing the 100 rows of a 1,000-row table, the ASP can use Response.Flush to force output of the 100 rows to the browser, where the user can see the first 100 rows of data, while the rest of the row data is ready to be generated.
Note that in the case of the above 1,000-Line table output, for some browsers, they will not output any contents of the table unless they encounter a </table > tag. If so, you can split the table into many tables that contain a small number of rows, and then invoke the Response.Flush output after each table is generated. The new version of Internet Explorer is not displayed until the entire table is downloaded, and if the column width of the table is defined, the table will be generated in a very fast speed.
Another problem with opening response buffering is that very large server memory is consumed when very large pages are generated.
Tip 12: Batch-line scripts and Response.Write commands
VBScript Syntax <% = expression% > means the value of the output expression. If response buffering is not open, each such statement will output data to the browser in the form of many small packets, which will degrade program performance. Therefore, use the following tips: Replace multiple lines of expression next to each other as a call and output with a Response.Write name. For example, in the following example, there is only one write for the output of each field in each row:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.