Tips for improving ASP applications

Source: Internet
Author: User
Tags html page variables thread client
ASP is Microsoft's launch of a server-side command execution environment, which allows you to easily create interactive Web applications. As one of the most widely used technologies for developing Web servers on NT platforms, its emergence replaces many of the things that used to be done with CGI technology, and the ASP's control of the database is simple and efficient, eliminating the large number of CGI programming work.

Because the ASP directly operates on the server, the technique of ASP design is very important, the improper ASP application can increase the burden of the Web server and reduce the performance of the server. I summed up a year to their own ASP design experience, I hope to be helpful to everyone, the wrong place I hope you correct me.

This article discusses mainly the performance improvement techniques of the ASP program, which includes two parts:

* Improve the performance of HTML page skills

* The technique of improving the reaction time of ASP program

I will discuss these two aspects in detail below.

1. Several tips for improving the performance of HTML pages

The performance of the HTML page is primarily related to the performance of the client's computer, which, in general, is closely related to the hardware of the client's computer and the bandwidth the customer has, and there are several factors that affect the performance of the HTML page:

As we all know, the smaller the page, the less time to load in the browser, the better the performance. Here are some useful tips for reducing the size of a page:

(1) Reduce the number of images: When your page contains n images, your browser sends n requests to the Web server, which wastes a lot of time, especially to avoid inserting a large number of images in the face when the bandwidth is narrower.

(2) Reduce the use of the framework: the framework is another way to reduce the speed of the page display elements, like the image, the browser will send the server n requests, therefore, also avoid a large number of frame use.

(3) Avoid the use of tables: although a beautiful page without the table, but we should reduce the use of unnecessary forms, which will speed up the loading of the page.

(4) Do not add comments in HTML

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

(6) When unnecessary, do not use the script, otherwise it will reduce the display speed of the page.

2. Several techniques to improve the reaction time of ASP program

Further points, improve the response time of ASP also involves three aspects of content:

* The performance of the ASP itself to improve the skills

* Network Bandwidth

* Improve the performance of the database skills

I will tell you the contents of these three aspects in detail below.

A Improving the performance of the ASP page itself

(1) Reading object variables is always slower than reading local variables, so you should develop the habit of transferring object variables to local variables, which improves the response time of the ASP, and the following two examples are a good contrast:

Slow Example:

If Myobj.value = 0 Then

Do slightly

ElseIf myobj.value > 0 Then

Do slightly

ElseIf Myobj.value < 0 Then

Do slightly

End If

A quick example:

MyVar = Myobj.value

If MyVar = 0 Then

Do slightly

ElseIf MyVar > 0 Then

Do slightly

ElseIf MyVar < 0 Then

Do slightly

End If

The quick example above is just a minor change, but there is a lot of improvement in performance.


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

(3) Generally, avoid the use of session variables, because each session variable takes up a thread, session calls are completed one after another. So this will reduce the speed of the ASP, you can use the QueryString set or hidden variables to replace the session variable to store the data. This will be less than the thread used to use the session variable.

(4) If you really can't avoid using session variables, and you have a large number of session variables, you should consider using a Dictionary object.

(5) To open the cache will improve the performance of ASP, such as the use of response.buffer=true in each ASP page is a good habit, it can significantly improve the display speed of the page.

(6) package your data read code into COM components, you will appreciate the compilation and multithreading to bring you the speed of ascension. As we all know, creating a database connection will cost a lot of resources and time, how can we solve this problem? When your component is running at Microsoft Transaction Server (MTS), the connection pool is a good solution to this problem. MTS is a technology based on Windows NT that, when used in conjunction with DCOM, allows you to better distribute COM objects over the network, which is better than using DCOM alone.

(7) Avoid calling COM components multiple times, for example, if you want to write 10 values to a COM component, you have to call 10 COM components, and if you can only call once, you can greatly improve overall performance.

(8) Don't declare COM components like ADO connection objects with application or session scope, because the thread invocations of these multithreaded components are coordinated, thus greatly reducing the performance of the ASP.

(9) When your ASP page has more than 100 lines of code, you'd better consider porting them to COM components, ASP scripts are interpreted at run time, and COM components are compiled.

(10) Do not use Microsoft Word or Excel components to manipulate data, which are not optimized for ASP.

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

(12) Avoid multiple use of request.write, it is best to put them in the whole and into a request.write.

B Network bandwidth

(1) Try to use 100M network card, this will greatly improve the ASP application response time.

(2) If your Web server and database are on the same server, it is recommended that you migrate them to a different database.

(3) It is recommended that COM components be used with MTS.

C Techniques for improving Database performance

A good database design method can greatly improve the performance of ASP programs, detailed discussion of this aspect of the content has been beyond the scope of this article, I only briefly introduce a few skills.

(1) When using the ADO recordset, be careful to use the cursor type and lock type two properties, for example, if you want to populate a combination list, you should set the cursor type to adopenforwardonly and lock type Set to adLockReadOnly.

(2) Sometimes the appropriate allocation of some database cache can improve the performance of ASP. For example, if you use Oracle as a database, a connection to open three conversations, if you can well reduce the number of connections, then your ASP performance will be the first mate upgrade.

(3) Note that the use of the correct database query statements, the scope of too large query action will waste a lot of time, so we must find ways to reduce the scope of the query, improve the speed of the query.

This article is finished, I declare again, if the article has the wrong place, I implore you to reply, also hope that the vast number of ASP lovers to learn from each other.



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.