Improves ASP Website execution speed

Source: Internet
Author: User

Write ASPProgramI have been downloading a lot of ASP source code for six years, and I can't say that I am an ASP.CodeExperts, I think writing a program is simple as long as the logic is clear, but it is not easy to write a program.

This articleArticleI just want to talk about one thing. How to improve the speed of ASP code execution. I hope it will be helpful to those who are website friends and the code writers must develop good habits.

First: anyone who may basically write ASP code knows that when the record set object is opened, it is necessary to close the connection object, for example, Rs. close, Conn. close, set rs = nothing, set Conn. close

Second, writing ASP code is inseparable from the database. Many users use select * from... to download the database.Source codeIn fact, these seemingly inconspicuous places greatly reduce the ASP execution speed. So I will tell you how many fields are used and how many fields are used. Of course, if you want to use all fields, there is not much difference in using *. Are you afraid of trouble, or are you concerned about speed, it's up to you.

Third, use stored procedures whenever possible. I don't know if stored procedures can be used for access, but I basically use stored procedures when operating MSSQL or Oracle databases, this method has two advantages unless complicated queries are encountered, because the stored procedure only compiles during creation and does not need to be re-compiled every time the stored procedure is executed, this increases the speed of your ASP program running. You do not need to perform SQL operations and compile the program once. The second advantage is to write a general stored procedure, which can reduce the amount of code. from the database perspective, the advantages of stored procedures will not be detailed here.

Point 4: Use a cursor to operate the database. If you only read a table, use forward-only, read-only cursor, because this type of cursor reads the database most quickly, especially when you read a large amount of data.

Fifth: many people may not know this, and I have never seen the downloaded source code. however, the performance can be improved by 5 times. many friends like to write RS ("username"), RS ("ADDR "), A friend who knows that the speed can be faster may write RS (1) and RS (2), but I tell you these two are not the fastest way, and they should write as soon as possible.
Dim objrs
Set objrs = RS (0)
Response. wirte objrs
When you get more than 100 records, you will feel the super advantage of this method. If you don't believe it, try it. Of course, don't forget set objrs = nothing.

Sixth point: Use the session object and Application object as few as possible
These two guys do bring a lot of benefits to our program, but they love and hate it. Why is it too much? The server is dragged to death by them, so here we cannot say that we should not use it, but we can only say that we can use it reasonably.

Point 7: if an object is used, remember to close it, just like the last sentence at the fifth point.

Eighth point: Use the include file reasonably
I have read a lot of downloaded source code, write all the functions to a file, and then include them in the places used. Although this makes great convenience, but there is always a reason for the performance discount. Yes, when you include this file on other pages, the server needs to pre-compile the file, it is very likely that there are hundreds of functions in a file, and you just want to use one of the functions, which is worth the candle. Therefore, try to split your contained files into multiple small contained files.

Ninth point: use functions provided by ASP as much as possible.

The tenth point: Dynamic Arrays should be used less, which is also the main engine that eats memory.

11th: declare variables in advance. programmers who do not have good habits write ASP programs, write any variables, and never see dim words. I want to tell you, declaring a variable in advance will speed up the interpretation and execution time of the program. without declaring the variable, not only will the program be difficult to read, but the execution efficiency of the entire program on the server will also be reduced.

12th: I saw a lot of downloaded code. I like to write the addition, deletion, and modification of all databases in a piece of code. This will slow your running speed down a lot, imagine how terrible it would be if 1000 people open this processing page at the same time. I suggest you write a logical event to a page independently, this reduces the burden on server-side interpretation and execution, and provides quick reading.

13th: Let's discuss how fast ASP is embedded in HTML? Or is it faster to print the entire webpage with response. Write?

Okey! Some may have doubts or methods to improve performance. Please tell me, don't go to the forum to discuss what languages are good and what languages are worth the money, any technology is learned and refined!

I still wrote the logic program in that sentence, but it is not easy to write the program. People have to sum up their heads and learn their skills!

Don't forget to add a source to a friend who wants to repost the article. It's really hard to write this article in hours.CompositionI have never been so serious about '@'

 

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.