|
Speed Tips by Charles Carroll
There are several ways to speed up a given ASP page.
#1 Any page that does not need session can benefit
from this directive at the top:
<%@ enablesessionstate=false
%>
#2 All pages should be buffered see /advice/whybuffer.asp
for explanation. Also see /freebook/asp/speedtables.aspx
to see how flushing buffer and HTML tags can improve percieved speed.
Add this to top:
<%response.buffer=true%>
#3 Pages doing database access will improve
performance if the following techniques are used
#4 Before just believing any article you read on the
web or in an ASP book (many articles are not researched thoroughly) and
implementing code changes TIME THE CODE BEFORE AND AFTER changes. /freebook/asp/speedtimer.aspx
has the needed code that will time scripts to millisecond accuracy.
#5 Eliminate any code that reads com properties twice,
/freebook/asp/propertyexpense.aspx
has some samples of this.
#6 Just say no to VB components and/or recordsets
stored at the session level. Several articles explain why:
#7 Cache frequent query results/HTML
generated from databases in application variables. http://www.learnasp.com/freebook/asp/speedappdata.aspx.
#8 Open database connections as late as
possible, Close database connections immediately when done. Placing your code a
few lines later could make a huge difference as your scripts run round-robin
with other scripts, see /advice/roundrobin.asp
for more whys about this.
#9 Tune your server. At least make the 20
instead of 4 thread tweak (see http://www.learnasp.com/advice/threads.asp).
The articles at /freebook/asp/speedserver.aspx
will tell you everything you need to know about tuning your server.
#10 Don't waste time running scripts if
the user hit the "stop" button or went to different page/site.
Normally scripts run started by a user run to completion whether the user is
there to read output or not running invisibly on server. See: /freebook/asp/isclientconnected.aspx
to see how to modify your scripts appropriately.
#11 Bite the bullet and master remote
scripting so your HTML and ASP scripts can communicate with ASP
asynchronously and refresh portions of page without submitting page to server.
Remote scripting works in both Netscape and IE; any Javascript capable browser.
|