How the ASP speeds up the Web site opening

Source: Internet
Author: User
Tags contains end variable access

One trick: increasing the efficiency of using the request collection
Accessing an ASP collection to extract a value is a time-consuming, resource-intensive process. Because this operation contains a series of searches for the related collection, this is much slower than accessing
a local variable. Therefore, if you intend to use a value in the request collection more than once in a page, you should consider storing it as a local variable.
For example, write your code in the following form to speed up script engine processing:
 

 
  
 
  1. strtitle=request.form ("Title")    
  2. strfirstname= Request.Form ("FirstName")    
  3. strlastname=request.form ("LastName")    
  4. If len (strtitle)  Then strTitlestrTitle=strTitle &  " "    
  5. if strfirstname= " Then strFullName=strTitle &   "  & strLastName   
  6. elseif len (strfirstname) =1 then   
  7. strfullname=strtitle & strfirstname &  ". "  &  strlastname   
  8. else   
  9. strfullname=strtitle &  strfirstname &  " "  & strLastName   
  10. end if   


Tip Two: Direct access to the appropriate set
Do not use the form of strpage=request ("page") to get the argument if it is not a choice, because it will search all the collections sequentially-
QueryString, Form, Cookies, ClientCertificate, servervarible until the name of the first matching value is found. This is more appropriate than direct access
The collection is inefficient and unsafe unless it is absolutely guaranteed that the value will not appear in another set.
For example, you might want to search for a Web server name that satisfies a customer request, which is found in the Request.servervarables collection in each query
"SERVER_NAME" to achieve. However, if the other collection also contains a value named "SERVER_NAME" (the key name is case-insensitive), use the request
("SERVER_NAME"), you get the wrong result. In summary, you should access the appropriate collection as direct as possible.


Tip Three: Use the Response.IsClientConnected property before a time-consuming operation
Using response.isclientconnected is a useful way to observe whether a user is still connected to the server and is loading the Web page created by ASP. If the user disconnects
Or stop downloading, we don't have to waste the server's resources creating pages because the buffer content will be discarded by IIS. So, for those who need a lot of time to compute or
Resources to use more pages, it is worth checking at each stage whether the visitors are offline:

 
  
 
  1. ...... Code to create the page
  2. If response.isclientconnected Then
  3. Response.Flush
  4. Else
  5. Response.End
  6. End If
  7. ...... Code to create next part of page



Related Article

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.