Strictly control Session
Content that does not require a Session (such as help screen, visitor area, etc.) can be moved to a standalone ASP application that closes the Session. On the basic page, you can give the ASP an instruction so that it does not require a Session. Add the following code directly to the head of the ASP page:
<%@EnableSessionState=False%>
Cache frequently used data on web servers
Typically, the ASP page retrieves data from the background storage and then forms the result in the form of Hypertext Markup Language (HTML). Regardless of the speed of the database, it is much faster to retrieve data from memory than from a background storage device. Reading data from a local hard drive is also usually very fast. Therefore, improving performance can be achieved by caching data on the server, whether it is cached in memory or in a local hard disk.
Caching is a classic "space for time" compromise. If cached properly, you can see significant performance improvements. In order to make the cache effective, it is necessary to ensure that the cached data is often reused and is cumbersome to calculate. A cache filled with stale data is a waste of memory.
Data that is not changed frequently is a better object for cache because there is no need to consider the synchronization operation after the update of these data at any time. Combo boxes, reference tables, DHTML code, extended markup language strings, menus, and site configuration variables (including data source names, Internet protocol address IPs, and web paths) are all good cache objects. Note: The data expression is cached instead of the data itself. If an ASP page changes frequently and is struggling to cache (such as the entire product catalog), you should consider pre-generating HTML instead of describing it every time a request occurs.
Cache frequently used data in Application or Session objects
Application and Session objects in ASP are convenient containers for cache data in memory. You can assign data to Application and Session objects, which will remain in memory during HTTP calls. The data in the Session is for every user, and the data in the Application is shared by all users.
When do I need to load data in Application and Session? Usually, data is loaded when the application starts or the session begins. In order to load data at this time, add appropriate code to Application OnStart() or Session OnStart() respectively. These functions are located in the file Global.asa and are added if they do not exist. You can also call the data when it is needed for the first time, add code to the ASP page to check whether the data exists. If it is not found, call it into it. Here is an example that represents a classic performance processing technique called "lazy evaluation": until needed, then go to the calculation.
Copy frequently used data into script variables
When accessing COM objects in ASP, you should copy frequently used object data into script variables, which reduces method calls to COM objects. These calls are relatively time-consuming and laborious than accessing script variables. Using this trick also reduces expensive lookup operations when accessing Collection and Dictionary objects.
Generally, if you want to access object data more than once, you should put the data into script variables, mainly the Request variables (form and query string variables). For example, a site wants to pass a query string variable called UserID. Assuming it will be referenced 12 times on a special page, then there is no need to call Request("UserID") 12 times. Just assign UserID a variable to the header of the ASP page and then use it in the page, this saves 11 calls to the COM method.