* Tip 1: Use Global.asa for application-tier files
Loads a file into an application-tier array in Global.asa instead of reading the file on the page by using an ASP file system pair.
GLOBAL. ASA can be used to specify event scripts or to declare objects that have session or application scope. Instead of displaying directly to the user, it stores information and objects for application-level events. You can then point to an array of application layers that have data through the page. This means that every server-side request to enroll in a file is not read every page per user. You can run a stand-alone ASP file to refresh the contents of the application-tier array, and you can also consider using dictionary (see Tip 9).
This technique can greatly speed up your system.
So how will this trick be implemented?
If you are a scripting person, you must use a file system pair like a read file into an array or a dictionary image. Then read the file in the Global.asa and place the array (with the contents of the file you read) or dictionary into the application-level declaration. This allows the user to access information in an array or dictionary image without having to submit the information each time through an ASP request.
But you might think, "What if the content in the cache needs to be updated?" I bet it's not going to work. Fact If the contents of the cache need to be updated, you can call an administrator-only accessible ASP file containing an executable application lock command script, update the cached information in an array or dictionary image, and finally execute the application Lockdown command.
* Tip 2: Remove the HTML annotation from the product source code (IIS3.0 applicable)
Yes, difficult to write must also be difficult to understand. A joke, this does not mean you have to remove all the HTML comments (the script annotation is good), a large range of HTML text can be copied to the client in batches. In this way, your script will run faster on IIS3.0 (in IIS4.0, HTML annotations will no longer cause slower execution).
* Tip 3: Multiple Response.Write statements
If you are writing the output in a format in several places in your code, consider putting the results together and writing with a Response.Write statement. Then you'll look at your HTML code and the composition of the VBScript script. Instead of spreading HTML and VBScript scripts too far, try to write chunks of HTML and VBScript scripts.
* Tip 4: Use the <OBJECT> flag example to
If you need to point to objects that may not be needed, use the <OBJECT> flag example instead of Server.CreateObject. The object is immediately generated with Server.CreateObject, and if you don't use it later, it's a waste of resources.
* Tip 5: Use local (local) variables as much as possible
(The following new techniques will replace the earlier issue of "defining variables within a row", which contains some erroneous ideas):
Local variables are defined in subroutines and functions (that is, variables that often say local scope) that are compiled into numbers to point to and put into a table. The points of these local variables can be completed by one compilation. The global variable is executed at run time. This means that local variables can be accessed several times faster than global variables. Also, multidimensional global variables are the slowest, and when a multidimensional global variable is used for the first time, the entire object model is searched for an object with the same name, before the new object is produced.
Here's a very common example:
Foo.bar.blah.baz = Foo.bar.blah.qaz (1)
If Foo.bar.blah.zaq = Foo.bar.blah.abc Then
The runtime produces the following results:
1 variable foo is defined as a global variable 2) variable bar is defined as a member of Foo (3) variable blah is defined as a member of the Foo.bar 4) variable Qaz is defined as a member of Foo.bar.blah 5) to invoke Foo.bar.blah.quaz ( 1) 6) Repeat 1 to 3. The system does not know if the call to Qaz changed the object model 1-3 steps must be performed again 7 to define Baz as Foo.bar.blah member, output value 8) Repeat 1-3, perform zaq9) repeat 1-3, perform ABC
As you can see, the quickest way to do this is to write the code in VBScript:
Set myobj = Foo.bar.blah ' Do the resolution of blah Oncemyobj.baz = Myobj.qaz (1) If Myobj.zaq = Myobj.abc Then
* Tip 6: Avoid repeating the definition of an array
When we use dim, avoid redefining the array. Because you might want to use ReDim to redefine the size of the array. As for such an operation, if your machine memory is not very large, it is best to consider the worst in the beginning to set the length of the array or set the length of the best state, when it is necessary to use ReDim. Of course this doesn't mean adding memory, if you don't need it very much.
The following examples illustrate improper use of ReDim
In fact, at the beginning of the definition of MyArray (5), and later need to use ReDim to increase his size, such words may occupy some memory, but the speed will be much faster.
* Tip 7: Avoid public (global) variables
Do not use variables that are defined with public. If you are writing VBScript or accessing variables in ActiveX controls or Java applets, avoid common variables as much as possible. Public keywords are usually designed for later use, and since public doesn't do you any good, it's best to use dim.
* Tip 8: Use absolute path
If possible, avoid using relative paths, and use absolute paths. Using a relative path will require IIS to return to the current server path, which means that the special requests for IIS cause low execution speed.
Note: Slow down, it's much more convenient to use a relative path to transplant anything.
* Tip 9: Use "Dictionary" for image
The Dictionary object provided in VBScript provides fast lookup and storage with any keyword data. The Dictionary object allows you to access the data in the array based on the keyword, so that you can find the content that is not contiguous in memory faster (because you are specifying the keyword you are using, rather than knowing where the image is stored in the array). If you're looking for non-linear keyword data, it's going to be a lot quicker to use the Dictionary object.
However, if the keyword data is contiguous in memory, the array will be faster to find and store the data. It is also necessary to note that indexing in dictionary is slower than in arrays. You should choose the data structure that works best for you.
* Tip 10: Take full advantage of the browser's fallback function
If you are using a smart browser, then he will help you do a lot of rollback work, as long as it is useful to use more. Then, perform a fallback through your script, and you can go back to the front when anything goes wrong and access the database from behind. But keep in mind that when you access a database that exists on the server, you perform a database operation once. If the form you want to return has a lot of variables, it's a bit of a draw. If you do know that you need to execute a lot of code on the client, move the code to the client to speed up execution. When you run on the client, the processor is yours, and the server has to use his own processing power to handle the requests he has received.
There's also a good idea that if you use a form that uses a lot of server-side scripting and has a lot of conditional input, it's best to put the trigger code in the client script engine (like Vbscript,javascript). Ignoring these, the server code runs fast, because the code that is not very necessary is not sent to the server side for execution. Of course, this is only for those relatively small code to apply, as for the big, it is not appropriate.
* Tip 11: Avoid using server-side variables
Accessing data through server-side variables requires the web to make a request to the server and then collect all the server-side variables, not just the variable you requested. It's like you're looking for something special from a box in a moldy attic. When you are looking for that thing, you first need to find the box from the attic. When you request a variable, the server is the same, triggering execution when it encounters the variable you requested, and then requesting the variable that does not cause the execution point.
* Tip 12: Use "Option Explicit"
Write in the ASP file. Unlike C, VB allows you to use this variable before you can force a variable to be defined. The Option Explicit opens to help identify undefined variables, and error messages appear using undefined variables. It is also possible to make the declared local variables illegal. A local variable that is not declared is as slow as a global variable (one times slower than a defined local variable). Turning on Option Explicit will naturally help you remove these bugs from your code.
* Tip 13: Copy the collected values to local (local) variables
If there are some values that you want to use repeatedly, copy the values to the client in the form of local variables. Each time you use these values, it saves you from going to the pile of values, which speeds up the script.
* Tip 14: Use the session pair with caution
Use the session object to store some user-specific information. When a user jumps between different pages of the application, the variables stored in the session are not lost, and instead, the variables are retained throughout the user's process. When a page is requested by a user who does not have a session, the Web server automatically establishes a sessions object. When the session time is limited to or is interrupted, the server undoes the sessions object. To avoid this, you can turn the session property off. However, the session attribute in iis3.0 in each application cannot be closed. Turning the session off throughout the server will be faster, but it will lose a lot of functionality. It is best to use the session pair as carefully as necessary
When you use a session-like image throughout your application, be careful to use it quickly, or the session pair will be reset. In Iis4.0, the session state in each application base can be activated, or it can be canceled in the specified.asp file.
* Tip 15: Do Performance testing
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