5 methods to speed up ASP Web pages

Source: Internet
Author: User

Methods for Improving ASP Web page speed 5 articles Source: Internet browsing times: 88 tips: improving the efficiency of using the request set to access an ASP set to extract a value is a time-consuming and computing resource-consuming process. This operation contains a series of searches for related sets, which is much slower than accessing a local variable. Therefore, if you want to use a value in the request set multiple times on the page, you should consider storing it as a local variable. For example, write the code below to speed up the processing speed 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 technology Coincidentally 2: directly access the appropriate set. If there is no choice, otherwise, do not use strpage = request ("page") to obtain parameters, because this will search all the sets in order-querystring, form, cookies, clientcertificate, and servervarible until the name of the first matching value is found. This is less efficient and insecure than directly accessing an appropriate set, unless it is absolutely guaranteed 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, which is achieved by searching for "SERVER_NAME" in the request. servervarables set in each query. However, if other sets also contain values named "SERVER_NAME" (key names are case-insensitive), an error is returned when request ("SERVER_NAME") is used. All in all, access the appropriate set as directly as possible. Tip 3: using the response. isclientconnected attribute to use response. isclientconnected before time-consuming operations is a useful way to observe whether the user is still connected to the server and loading the web page created by ASP. If you disconnect or stop downloading, you do not need to waste resources on the server to create a webpage, because the buffer content is discarded by IIS. Therefore, for web pages that require a large amount of time computing or resource usage, it is worth checking whether the browser is offline at each stage :...... Code to create first part of the page if response. isclientconnected then response. Flush else response. end if ...... Code to create next part of page Tip 4: optimize the ADO operations in ASP, data constitutes the actual content of the web site. Therefore, it is very useful to optimize ADO operations to accelerate ASP code execution:. select only the required columns: When opening the ADO record set, the table name (select *) should not be used automatically unless all columns are obtained *). Using a separate column means reducing the amount of data sent to or from the server. Even if you need to use all columns, naming each column independently will achieve the best performance, because the server no longer needs to explain the names of these columns. B. Use stored procedures as much as possible. Stored procedures are pre-compiled programs that contain a prepared execution plan, so they are faster than SQL statements. C. Use the appropriate cursor and lock mode. If all the work is to read data from the record set and display it on the screen, the default record set can only be moved forward and read-only. The less detailed ADO is to maintain records and locks, the higher the execution performance. D. Use object variables. When traversing a record set, one way to improve performance is to use object variables to point to Members in the set. Example: while not rsgc. EOF response. write "Project name:" & rsgc ("GCMC") & "(project code:" & rsgc ("gccode") & ")" rsgc. movenext Wend can be rewritten to 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. the new movenext Wend Code creates an object variable reference, so you can use an object variable instead of an actual variable, which means that the script engine has reduced its work, because the number of indexes in the set is reduced. Tip 5: Do not mix the script engine. We know that VBSCRIPT or JScript can be used on ASP pages. However, JScript and VBScript cannot be used on the same page at the same time. Because the server must instantiate and try to cache two (rather than one) script engines, which increases the burden on the system to a certain extent. Therefore, in terms of performance, you should not mix multiple script engines on the same page.

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.