Strictly control sessions
You can move unnecessary Session content (such as the help screen, visitor area, and so on) to an independent ASP application that closes the Session. On the Basic page, you can give ASP an instruction so that it does not need to use Session. Add the following code to the header of the ASP page:
<% @ EnableSessionState = False %>
Cache frequently used data on Web Servers
A typical scenario is that an ASP page retrieves data from the backend storage and generates results in the form of HTML. Regardless of the database speed, retrieving data from the memory is much faster than retrieving data from the back-end storage device. Reading data from a local hard disk is usually very fast. Therefore, to improve performance, you can cache the data on the server, whether by caching the data in the memory or on the local hard disk.
Cache is a classic compromise between "space for time. If the cache is appropriate, you can see significant performance improvement. To make the cache effective, it is necessary to ensure that the cached data is often reused and complicated to compute. Cache filled with old data is a waste of memory.
The infrequently changed data is a good cached object, because the updated data synchronization operation is not required at any time. The combo box, reference table, DHTML code, Extended Markup Language string, menu, and site configuration variables (including the data source name, Internet Protocol IP address, and Web path) are good cache objects. Note: You must cache the data expression instead of the data itself. If an ASP page changes frequently and is difficult to cache (such as the entire product directory), you need to consider pre-generating HTML instead of describing it every time a request occurs.
Cache frequently used data in Application or Session objects
The Application and Session objects in ASP are convenient containers for caching data in the memory. You can assign data to the Application and Session objects, which will remain in the memory during HTTP calls. The data in the Session serves every user, and the data in the Application is shared by all users.
When do I need to load data in the Application and Session? Generally, data is loaded when the application starts or the session starts. To load data at this time, add the appropriate code in Application OnStart () or Session OnStart. These functions are located in the Global. asa file. If they do not exist, add them. You can also add code to the ASP page when the data is required for the first time to check whether the data exists. If no code is found, call it. Here is an example, which represents the classic performance processing technology called "lazy evalution": Compute again until necessary.
Copy frequently used data to script variables
When accessing a COM Object in ASP, copy frequently used object data to the script variable, thus reducing the call to the COM Object method. These calls are more time-consuming and labor-consuming than accessing script variables. This technique reduces expensive search operations when accessing Collection and Dictionary objects.
Generally, if you need to access object data more than once, you should put the data into the script variable. The object data is mainly the Request variable (Form and query string variable ). For example, if the site needs to pass a query string variable named UserID, if it will be referenced for 12 times on a special page, it does not need to call Request ("UserID") for 12 times, you only need to allocate a variable to UserID in the header of the ASP page and use it on the page. This saves 11 times of COM method calls.
Use Server. Transfer whenever possible, instead of Response. Redirect
Response. Redirect tells the browser to request another different page, which is often used to guide the user to the login page or error handling page. As redirection forces a new page request, the result is that the browser must loop twice with the Web server, and the Web server must process an additional request. Server. Transfer executes page transmission on the same Server. This will avoid the data loop of the additional browser-Web Server, forming good system performance and providing better response time for users. Of course, Server. Transfer only supports relative paths (that is, intra-site use ).