More and more people have given up ASP. In fact, ASP is not very bad. It is easy to learn and get started quickly. Read the following articles and understand how to speed up in ASP!
One of the techniques: Improve the efficiency of using the Request collection
Access a ASP collection to extract a process of time and consuming computing resources. Because this operation contains a series of search for related collection, which is more accessible
A local variable is much slower. Therefore, if you plan to use a value in the Request collection multiple times in the page, you should consider storeing it as a local variable.
For example, write the code into the following form to speed up the script engine processing speed:
strTitle=Request.Form(Title)
StrfirstName = request.Form (firstName)
Strlastname = request.form (LastName)
If len (StrTitle) then StrTitle = StrTitle &
If strfirstName = then StrfulLLLLLLLNAME = StrTitle & & Strlastname
Elseif Len (StrfirstName) = 1 then
StrfulLName = StrTitle & StrfirstName &. & Strlastname
Else
StrfulLName = StrTitle & StrfirstName & & Strlastname
End if
Tips: Direct access to the appropriate collection
If it is not no choice, do not use strpage = Request (PAGE) to obtain parameters, because this will search for all the collection in order-
QueryString, Form, Cookies, ClientCertificate, Servarible until the first match name is discovered. This is better than the direct access
The collection efficiency is low and unsafe, unless it can absolutely ensure that this value will not appear in another set.
For example, you may want to search for the name of the web server that meets the customer's request.
Server_name to implement. However, if other sets also include the value named Server_name (the key name is not distinguished), use Request
(Server_name), the error result will be obtained. All in all, you should directly access the appropriate collection as much as possible.
Tip 3: Use response.isClientConnected property before time -consuming operation
Using Response.IsclientConnect is useful to observe whether the user is still connected to the server and is loading the web pages created by ASP. If the user is disconnected
Or stop downloading, we don't need to waste the server's resources to create a web page, because the buffer content will be discarded by IIS. Therefore, for those who need a lot of time to calculate or
For the webpage with more resources, it is worth checking whether the tourists are offline at each stage:
…… Code to create first part of the page
If response.isClientConnect then
Response.flush
Else
Response.end
End if
... code to create next part of page
Tip 4: Optimize the ADO operation in ASP
Usually, the data constitutes the actual content of the web site. Therefore, optimizing the ADO operation to accelerate the ASP code, which is very useful:
a. Choose only the required columns: When opening the ADO record set, unless you need to get all columns, you should not automatically use the table name (ie, Select *). Use alone
The meaning of the columns will be reduced to the amount of data from the server or taken from the server. Even if you need to use all columns, you will get the best sex by name each column alone
Yes, because the server does not have to explain the names of these columns.
b. Use the storage procedure as much as possible. The storage procedure is a pre -compiled program, which contains a prepared execution plan, so it is performed faster than the SQL statement.
c. Use appropriate cursor and lock mode. If all the work you do is to read data from concentrated records and display it on the screen, then use the default
Can only move forward and read only. The less the ADO is used to maintain the details of the records and locks, the higher the performance.
d. Use object variables. A method that can definitely improve the performance when the traversal record set is to use the object variable to point to the members in the collection. For example:
While Not RsGc.EOF
Response.write project name: & rsgc (GCMC) & (engineering code: & rsgc (gccode) &)
Rsgc.movenext
Wend
You can use the code below to speed up the execution:
set GcMc=RsGc(GcMc)
set gccode = RSGC (gccode)
While Not RSGC.EOF Response.write Engineering Name: & GCMC & (Engineering Code: & GCCode &)
Rsgc.movenext
Wend
The new code establishes a reference to the object variable, so it can use object variables instead of actual variables, which means that the work of the script engine is reduced, because in the collection
The number of indexes in the union has become less.
Tip 5: Don't mix the script engine
We know that the ASP page can use VBScript or JScript. But use JScript and VBScript on the same page at the same time
Tool. Because the server must instantiate and try to restore two (not one) script engine, this increases the system burden to a certain extent. Therefore, nature
It can be considered that multiple scripts should be used on the same page.