Four tips for optimizing ASP applications

Source: Internet
Author: User
This article will introduce four tips for optimizing ASP applications.
1. Cache frequently used data in Application or Session objects
ASP Application and Session objects provide a convenient container for saving data in the memory. You can assign data to the Application and Session objects, which are stored in memory before the HTTP call. Session data is stored separately by each user, while Application data is shared among all users.
When will the data be loaded into the Application or Session? Generally, data is loaded when an Application or Session is started. To load data during Application or Session startup, add the appropriate code to Application_OnStart () or Session_OnStart. These functions should be in Global. asa. If not, we can manually add them. You can also load the data at the first time you need it. To this end, add some code (or write a reusable script function) to the ASP page to check whether the data exists. If not, load the data. This is a traditional technology for improving performance. It is called "inert computing", that is, it is not calculated until you know that a value is required. The program example is as follows:
<%
Function GetEmploymentStatusList
Dim d
D = Application (? EmploymentStatusList ?)
If d = ?? Then
'Fetchemploymentstatuslist function (not shown)
'Fetches data from DB, returns an Array
D = FetchEmploymentStatusList ()
Application (? EmploymentStatusList ?) = D
End If
GetEmploymentStatusList = d
End Function
%>
We can write similar functions for each required data block.
2. Encapsulate code in COM object
If your Web application contains a lot of VBScript or JScript code, you can often move the code to the compiled COM object to improve performance. Encapsulating code in COM objects has some other advantages besides improving performance:
(1) the COM object is conducive to separating the representation logic from the business logic;
(2) the COM object can be used repeatedly;
(3) code written with VB, VC ++, or Visual J ++ is easier to debug than ASP.
COM objects also have disadvantages, including long initialization time and different programming skills. It is worth noting that when a small amount of ASP code is encapsulated into a COM object, it may not improve the performance, but may lead to performance degradation. This usually means that the system overhead for creating and calling COM objects exceeds the system overhead for compiling code. Therefore, we need to experiment repeatedly to determine the combination of ASP scripts and COM object code to produce the best performance.

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.