Active Server pages can allow dynamic pages to execute quickly, but with a few tricks in the code and connections to the database, the program executes faster. This is an article on how to refine the scripting and ASP features to achieve maximum speed. Any delay between the user clicking on the button and the result appearing on the screen will leave the user dazed, and for a commercial site, this means a potential user loss.
size of ASP script
We may not be able to control the user's bandwidth, but by optimizing the ASP site, we do have the best performance for the application. Many potential performance gains can be adjusted through the system, rather than changing the code.
Factors
First, what are the factors that can affect the performance of an ASP program? Unfortunately, is there a lot of it? Here are just a few:
Limited bandwidth
The speed of the server-side processor and other hardware
Other processes running on the server (for example, one of those OpenGL screen savers)
Database connection mode, connection pooling, or separate database (Oracle, SQL Server, Access, for example)
Language in use
Stored Procedures and SQL
Using non-compiled components instead of VB or Javsscript ASP
Good programming habits, such as the handling of errors
Some of these features are common to an experienced developer with good IIS knowledge, but others can be very complex. In this article, let's look at how we can save millisecond-level time, rather than trying to be exhaustive.
Does your ASP script appear to be too long for the implemented functionality? This will affect the performance of the program from the start. ASP scripts are useful for collecting information and formatting output, but scripts are interpreted as rows, so the longer the code, the longer it takes to execute.
If you have a long ASP script, how can you reduce the length? Here are some suggestions.
You can convert them to server-side components, in other words, create a visual Basic DLL file, or use any modern Windows programming language and COM-compatible language to build a non-compiled component and register it on the server. For a tutorial on this feature, see http://www.webdevelopersjournal.com/articles/activex_for_asp.html. A well-written ActiveX component not only improves speed significantly, but it also greatly improves the protection of your software, especially if you are developing ASP programs for 3rd parties.
Because the script is interpreted in a row of lines, it can improve program performance by excluding redundant scripts or by building efficient scripts. If you have hundreds of ASP scripts in a single page, you might be able to split the program into user, business, and data services parts well. In fact, if you do, you'll find some extra code. For example, if you need to display several tables, you can write a common table display function, so that you can call where you want.
Another dimension-related problem is the length of the included file. When an # include file is executed, the entire file is called in, just as it exists in the contained file. So, if you have a Yong-Yu containing file that contains many global methods and variable definitions, be aware that they will be called into every file that contains them, regardless of whether they are available. ASP caches all extension codes, resulting in inefficient searches. In this case, the include file must be smaller. Although the include file is processed by the server as a separate request, an excessive use of # include will result in an excessive download time.
<!--#include file= "header.asp"-->
<!--#include file= "footer.asp"-->
< SCRIPT language= "VBScript" runat= "Server" >
Sub Main ()
Writeheader
Writebody
Writefooter
End Sub
Sub Writebody ()
...
End Sub
Main ' Call Sub Main '
</script >
If the script is long, be aware that you want to use the response.isclientconnected command, which avoids the CPU wasting run cycle when the client is no longer connected.
<%
' Check to see if the client is connected
If not Response.IsClientConnected Then
' Still connected so proceed
Else
' Disconnected
End If
% >
Decentralized ASP code and HTML language commands
Did anyone do this? When describing a table, switch between ASP and HTML, such as:
< HTML;
< BODY;
<%
Set myconn = Server.CreateObject ("ADODB. Connection ")
Mdbfilepath = Server.MapPath (" Sample.mdb ")
MyConn.Open" Driver={microsoft Access Driver (*.mdb)}; Dbq= "& Mdbfilepath &"; "
Sql_query = "SELECT * from Friends"
Set rs = Myconn.execute (sql_query)
and not Rs. EOF
%;
< LI ><%=rs ("Name")%: < A href= "<%=rs (" Link ")% >" >Homepage</A;
& L T %
RS. MoveNext
Wend
%;
</body;