Improve ASP application skills

Source: Internet
Author: User

ASP is a server-side Command Execution Environment launched by Microsoft. It allows you to easily create interactive web applications. As one of the most widely used technologies for developing Web servers on the NT platform, its appearance replaces many things that can only be done using CGI technology in the past, in addition, ASP is simple and effective for Database Control, saving a lot of CGI programming work.

Because ASP directly operates on servers, ASP design skills are very important. Improper ASP applications will increase the burden on web servers and reduce server performance. I have summarized my experience in ASP design over the past year. I hope it will be helpful to you. I hope you can correct the mistakes.

This article mainly discusses the performance improvement skills of ASP programs, which includes two parts:

* Tips for improving HTML page performance

* Tips for improving the response time of ASP programs

Next I will discuss these two aspects in detail.

1. Tips for improving the performance of HTML pages

The performance of the HTML page is mainly related to the performance of the client computer. In general, it is closely related to the hardware of the client computer and the bandwidth of the client. In addition, several factors also affect the performance of HTML pages:

As we all know, the smaller the page, the less time it takes to load in the browser, and the better the performance. The following are some useful tips to reduce the page size:

(1) Reduce the number of images: when your page contains n images, your browser will send n requests to the web server, this will waste a lot of time, especially when the bandwidth is relatively narrow, avoid inserting a large number of images in the area.

(2) reduce the frame usage: the frame is another element that reduces the page display speed. Like an image, the browser sends n requests to the server. Therefore, A large number of frameworks should also be avoided.

(3) Avoid using tables: Although tables are indispensable for a beautiful page, we should reduce the use of unnecessary tables, which will speed up page loading.

(4) do not add comments to HTML

(5) Avoid using long file names and develop the habit of using relative paths.

(6) When unnecessary, do not use scripts. Otherwise, the page display speed will be reduced.

2. Several tips for improving ASP program response time

Further improvement of ASP response time involves three aspects:

* ASP performance improvement skills

* Network bandwidth

* Database performance improvement skills

Next I will detail these three aspects in detail.

A. Skills for improving the performance of ASP pages

(1) Reading object variables is always slower than reading local variables. Therefore, you should develop the habit of transferring object variables to local variables, which will improve ASP response time, the following two examples are a good comparison:

Slow example:

If myobj. value = 0 then

Do omitted

Elseif myobj. value> 0 then

Do omitted

Elseif myobj. value <0 then

Do omitted

End if

Example:

Myvar = myobj. Value

If myvar = 0 then

Do omitted

Elseif myvar> 0 then

Do omitted

Elseif myvar <0 then

Do omitted

End if

Although the above example is just a small change, it has improved a lot in terms of performance.

(2) If you are using VBScript 5.0 or a later version, you can use ...... End with structure, which can also improve ASP performance a lot.

(3) Generally, avoid using session variables. Because each session variable occupies one thread, Session calls are completed one by one. Therefore, this will reduce the ASP speed. You can use querystring sets or hidden variables to store data instead of session variables. This will reduce the number of threads occupied by session variables.

(4) If you cannot avoid using session variables and you have a large number of session variables, you should consider using dictionary objects.

(5) Opening the cache will improve ASP performance. For example, it is a good habit to use response. Buffer = true in every ASP page. It can significantly increase the page display speed.

(6) package your data read code into a COM component, and you will see the speed improvement brought by compilation and multithreading. As we all know, it takes a lot of resources and time to create a database connection. How can this problem be solved? When your component runs on Microsoft Transaction Server (MTS), you can use the connection pool to solve this problem. MTS is a technology based on Windows NT. When used together with DCOM, it allows you to better distribute COM objects on the network, which is better than using DCOM alone.

(7) Avoid calling the COM Component Multiple times. For example, if you want to write 10 values to the COM component, you have to call the COM component 10 times. If you can only call the COM component once, this will greatly improve the overall performance.

(8) do not declare COM components such as ADO connection objects together with the application or session scope, because the thread calls of these multi-threaded components have to be coordinated, thus greatly reducing ASP performance.

(9) When there are more than 100 lines of code in your ASP page, you 'd better consider porting them to the COM component. The ASP script is explained during running, the COM component is compiled.

(10) do not use Microsoft Word or Excel components to operate data. These components are not optimized for ASP.

(11) when developing Web applications, we always like to create a large include file containing all global variables, but the biggest drawback of this method is that not all pages need these variables, and each page needs to process these variables, which will greatly affect the ASP speed.

(12) Avoid using request. Write multiple times. It is best to merge them into a request. Write.

B. network bandwidth

(1) try to use a m Nic, which will greatly improve the response time of ASP applications.

(2) If your web server and database are on the same server, we recommend you port them to different databases.

(3) we recommend that you use the COM component together with MTS.

C. database performance improvement skills

A good database design method can greatly improve the performance of ASP programs. The detailed discussion of this content is beyond the scope of this article. Here I will only briefly introduce several skills.

(1) When using ADO recordset, pay attention to using the cursor type and lock type attributes. For example, if you want to fill in the combination list, set cursor type to adopenforwardonly and lock type to adlockreadonly.

(2) Sometimes it is appropriate to allocate some database caches to improve ASP performance. For example, if you use ORACLE as a database, you need to open three conversations for one connection. If you can reduce the number of connections, your asp performance will be greatly improved.

(3) Pay attention to the use of correct database query statements. A large range of query operations will waste a lot of time. Therefore, we must try our best to reduce the query range and increase the query speed.

This article has been written here. I again declare that if there is something wrong in the article, please reply and correct it, and I hope that the majority of ASP fans will learn from each other.

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.