[Home]  [Edit this page]  [Recent Changes]  [Special Pages]  [Help
ASPFAQ_OptimizationTips

ASP Optimization Tips

Back to ASP FAQ Main Page.

This page contains tips on how you can make your ASP WEB-site faster.

Disable Session State
Does your .ASP page require session state? If not it's wise to disable session state for all .ASP pages that does not need session state.

You can disable session state by adding the following to the top of the page:

<%@ ENABLESESSIONSTATE=false %>


Always use Option Explicit
Always start your ASP page with the following line

<% Option Explicit %>


Because that will eliminate bugs due to mis-spelling of variable names. Option Explicit requires that all variables are declared using the "dim" statement before they can be used. It also improves the page's performance by up to 10% according to some tests.



Disable ASP Server-side Debugging
Make sure that the ASP server-side script debugging is disabled on your production server because that will otherwise slow down the your server. If you enable ASP-debugging the application will be locked to a single execution thread. You can disable it in the Application Configuration window that you will find in the IIS property page.

Use local variables
Using variables defined inside functions or subroutines are faster than global variables.

Use the ordinal form when accessing recordset fields
Its faster to refer to a field value in a recordset using its ordinal number instead of its name. The ordinal number represent the column number in the record and the number starts counting from zero. By refering to it by name a extra lookup has to be performed every time its accessed.

Here's a example
     'Using the slower name to refer to a field value
     Response.write "Hello " & Rs("Hame")
     'Using the faster ordinal number (asuming that the number is 1)
     Response.write "Hello " & Rs(1)


Using ordinal number is specially efficient to use inside loop.

You can here find a good article about this.

Use the Recordset's .CacheSize property
If you are retrieving more than one record from your database you might gain some extra performance by setting the Recordset's .CacheSize property to a suitable level. A suitable level depends on your application and the type of query you are making.

You can find more information about this here





last edited (December 30, 2002) by WEBMASTER, Number of views: 4347, Current Rev: 8 (Diff)

[Edit this page]  [Page history]  [What links here]  [Discuss this topic]  [Printer Friendly]  

Members

Username:

Password:


Register
Forgot Password?




Programmers Heaven - for .NET, Java, C/C++ and WEB Developers!
© 1996-2008 Community Networks Ltd. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Development by Tore Nestenius at .NET Consultant - Synchron Data.