Chapter 10 Achieving Optimum Performance with PowerDynamo
One of the most expensive tasks of a Web site is generating the output of a dynamic document. Caching a document's output with the cachedOutputTimeOut property can significantly reduce the time required by a Web site to respond to a request.
Write Web documents so as many as possible use cacheable output and have a cachedOutputTimeOut value assigned.
The following Web documents do not produce cacheable output:
Output that use variables given by the user are a good example of non-cacheable output. The first script in the example below, multiIntro.stm, displays a list of radio buttons for users to select the price range of products they would like to see.
<HTML> <TITLE>multiIntro.stm</TITLE> <BODY> <H1>Product List</H1> <P>The following items are available from the sample database</P> <!--SQL SELECT name FROM product --> <TABLE BORDER> <TR> <TH>name</TH> </TR> <!--formatting--><TR> <TD><!--data--></TD> </TR><!--/formatting--> </TABLE> <P>Enter the price range you would like displayed</P> <FORM METHOD=POST ACTION="mulchoice.stm" MULTIPLE SIZE="5"> <OL> <INPUT TYPE="radio" NAME="choice" value="less10">Less than $10<BR> <INPUT TYPE="radio" NAME="choice" value="less20">Less than $20, more than $10<BR> <INPUT TYPE="radio" NAME="choice" value="less30">Less than $30, more than $20<BR> </OL> <P><INPUT TYPE="submit" VALUE="Submit List"></P> <P><INPUT TYPE="RESET" VALUE="Clear Form"></P> </FORM> </BODY> </HTML>
multiIntro.stm calls the following script, which in turn calls one of three scripts depending on the parameter being passed:
<HTML> <TITLE>Selected Products</TITLE> <BODY> <!--SCRIPT if( document.value.choice == "less10" ){ x=site.Include('choice1.stm'); document.WriteLn(x); } if( document.value.choice == "less20" ){ x=site.Include('choice2.stm'); document.WriteLn(x); } if( document.value.choice == "less30" ){ x=site.Include('choice3.stm'); document.WriteLn(x); } --> </BODY> </HTML>
<H1>The following items are under $10.00 in price</H1> <!--SQL SELECT product.name, product.color, product.unit_price FROM DBA.product product WHERE product.unit_price <= 10.00 --> <TABLE BORDER> <TR> <TH>name</TH> <TH>color</TH> <TH>unit_price</TH> </TR> <!--formatting--><TR> <TD><!--data--></TD> <TD><!--data--></TD> <TD><!--data--></TD> </TR><!--/formatting--> </TABLE> <!--DOCUMENT CACHED_OUTPUT_TIMEOUT = 10 -->
<H1>The following items are $10.00 to $20.00 in price</H1> <!--SQL SELECT product.name, product.color, product.unit_price FROM DBA.product product WHERE product.unit_price <= 20.00 and product.unit_price >= 10.00 --> <TABLE BORDER> <TR> <TH>name</TH> <TH>color</TH> <TH>unit_price</TH> </TR> <!--formatting--><TR> <TD><!--data--></TD> <TD><!--data--></TD> <TD><!--data--></TD> </TR><!--/formatting--> </TABLE> <!--DOCUMENT CACHED_OUTPUT_TIMEOUT = 10 -->
<H1>The following items are $20.00 to $30.00 in price</H1> <!--SQL SELECT product.name, product.color, product.unit_price FROM DBA.product product WHERE product.unit_price <= 30.00 and product.unit_price >= 20.00 --> <TABLE BORDER> <TR> <TH>name</TH> <TH>color</TH> <TH>unit_price</TH> </TR> <!--formatting--><TR> <TD><!--data--></TD> <TD><!--data--></TD> <TD><!--data--></TD> </TR><!--/formatting--> </TABLE> <!--DOCUMENT CACHED_OUTPUT_TIMEOUT = 10 -->
Copyright © 2001 Sybase, Inc. All rights reserved. |