Tip one:improve the efficiency of using the request collection
Accessing an asp collection to extract a value is a time-consuming and computationally intensive process.Because this operation involves a series of searches for related collections,This is much slower than accessing a local variable.Therefore, if you intend to use a value from the request collection multiple times in a page,You should consider storing it as a local variable.For example, write the code in the following form to speed up the processing of the script engine:
strtitle=request.form ("title") strfirstname=request.form ("firstname") strlastname=request.form ("lastname") if len (strtitle) then strtitle=strtitle&"" if strfirstname="" then strfullname=strtitle&""&strlastname elseif len (strfirstname)=1 then strfullname=strtitle&strfirstname&"."&strlastname else strfullname=strtitle&strfirstname&""&strlastname end if
Tip #2:Direct access to the appropriate collection
If there is no other choice,Otherwise don't use strpage=request ("page") to get parameters,Because this will search all the collections querystring, form, cookies, clientcertificate, servervarible in order until the name of the first matching value is found.This is less efficient than accessing the appropriate collection directly,And is not safe,Unless it is absolutely guaranteed that this value will not appear in another set.
For example, you might want to search for a web server name that meets a client's request,This is done by looking for "server_name" in the request.servervarables collection that appears in each query. However, if other collections also contain a value named "server_name" (key names are not case sensitive), you will get incorrect results when using request ("server_name").all in all,Whenever possible, access the appropriate collection directly.
Tip #3:Use the response.isclientconnected property before time-consuming operationsUsing response.isclientconnected is a useful way to observe if the user is still connected to the server and is loading a web page created by asp.If the user disconnects or stops downloading,We no longer need to waste resources on the server to create web pages,Because the buffer contents will be discarded by iis. So, for pages that require a lot of time to calculate or use a lot of resources,It's worth checking if the visitor is offline at each stage:
... code to create first part of the page if response.isclientconnected then response.flush else response.end end if ... code to create next part of page
Tip four:optimize ado operations in aspIn general,The data constitutes the actual content of the web site.So, optimize ado operations to speed up asp code execution,Very useful:
a. Select only the required columns:When opening the ado recordset,Unless you need to get all the columns,Otherwise, the table name (ie select *) should not be used automatically. Using separate columns means reducing the amount of data sent to or fetched from the server.Even if you need to use all columns,Name each column separately for best performance,Because the server no longer has to interpret the names of these columns.
b. Use stored procedures whenever possible.Stored procedures are precompiled programs,Contains a prepared execution plan,So it executes faster than SQL statements.
c. Use the appropriate cursor and lock modes.If all that is done is reading data from a recordset,And display it on the screen,Then use the default forward-only, read-only recordset.The less work Adobe does to maintain the details of records and locks,The higher the performance of the execution.
d. Use object variables.One way to definitely improve performance when traversing a recordset is to use object variables to point to members of the collection.E.g:
while not rsgc.eof response.write "Project name:"&rsgc ("gcmc")&"(Project code:"&rsgc ("gccode")&") " rsgc.movenext wend
You can use the following code to speed up execution:
set gcmc=rsgc ("gcmc") set gccode=rsgc ("gccode") while not rsgc.eof response.write "Project name:"&gcmc&"(Project code:"&gccode&") "rsgc.movenext wend
The new code establishes a reference to the object variable,So you can use object variables instead of actual variables,This means less work for the scripting engine,Because the number of indexing in the collection is reduced.
Tip five:don't mix script enginesWe know thatAsp pages can use either vbscript or jscript. But using jscript and vbscript on the same page is not advisable.Because the server must instantiate and try to cache two (rather than one) script engines,This increases the burden on the system to a certain extent.Therefore, from a performance perspective,You should not mix multiple script engines on the same page.
- python - you may need to restart the kernel to use updated packages error
- php - coincheck api authentication doesn't work
- php - i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
- [php] i want to get account information using coincheck api
- the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
- python 3x - typeerror: 'method' object is not subscriptable
- i want to call a child component method from a parent in vuejs
- xcode - pod install [!] no `podfile 'found in the project directory
- dart - flutter: the instance member'stars' can't be accessed in an initializer error