Performance optimization of ASP program

Source: Internet
Author: User
Tags execution functions variables xml parser client access
Program | performance | optimization

  Chapter one using server caching

1. Techniques for saving data using application and session.

You can assign the required data to the application and Session object at the start of the program or at the beginning of the conversation. Using this method, you only need to add a response assignment function or statement to the Application_OnStart and Session_OnStart functions of the Global.asa file.

The ADO records themselves can be cached under appropriate conditions, but note:

1.ADO records must be free thread-flagged

2. Set of records that have been disconnected when necessary

3. Caching data on the server's hard disk

Data that is large in size and not very high in frequency can be cached on the hard disk using text and XML. For a single page, the speed of accessing the database is not necessarily less than the speed of the hard drive, but for a large number of pages, this reduces the server's access to the database, and is a good way to optimize the stored procedures in the database that require a lot of caching.

ASP and COM provide several disk-buffering-based configuration tools. The Save () and open () functions of the ADO Recordset are the set of records that are responsible for saving and dropping onto the disk. In addition, some components can achieve similar functions:

1.scripting.filesystemobject: Create, read and write files with Xu

2.msxml:microsoft XML parser, brought in with Internet Explorer, supports and saves and loads XML documents

3.Lookup Table object: A good choice for dropping a simple list from disk.

4. Avoid caching non-brisk components in application and Session objects

5. Do not cache database connections in application or session objects

6. Reasonable use of Session object

  Chapter II improve the efficiency of code execution

1. Use Option Explicit

Using <%option explicti%> in ASP files can improve the efficiency of ASP code execution. Opening this key helps you to identify variables that are not defined, and you will receive an error message using variables that are not defined.

2. Avoid repeating the definition of an array

It is best to prepare for the worst in the first place, the length of the array should be considered sufficiently to avoid the use of ReDim

3. Using the Dictionary object

The Dictionary object provided in VBScript provides quick lookup and functionality for any generation of keyword data storage. The Dictionary object allows you to access the data in the array based on the keyword, so you can find the content that is not contiguous in memory. Note, however, that if the keyword is contiguous in memory, it will be faster to find and store the data in the array.

4. Avoid using string concatenation operations in loops

The first is the time that repeats a continuous string consumes two of times, followed by the relationship between the time of the run and the number of fields that are computed. You can use a replacement string to connect to a Response.Write or inline scripting <%=fl.value%> to improve the performance of your program. If you are using JScript, it is highly recommended that you use the "+ +" action instead of S=S+STR

  Chapter three optimizing the work of the server

1. Multiple Response.Write declarations

If you are using <%=...%> for multiple results, consider using Response.Write output for your data

2. Where possible, use Server.Transfer instead of Resonse.redirect

Server.Transfer is the content of the page in the server, and the specific content sent to the client browser, and Response.redircet to the server itself to request the next page content, so increased the burden on the network and the client.

3. Avoid using server Variables

4. Create objects with <object> logo

When you create an object using Server.CreateObject, an object is immediately generated, but there are times when the object is not used, which is wasteful, and the use of the <object> server does not really create the object, and the object is created only when the object is used.

5. Use absolute path whenever possible

6. Use of Response.Buffer

TCP/IP is more efficient at sending large packets than sending a large number of small packets

7. Use response.isclientconnected to determine whether the client is connected before sending a large amount of content

8. Adjust the Web server

9. Even upgrade, use the latest version of the product

  The fourth chapter uses the browser to work

Validate a form with a client for validation checks



Related Article

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.