To read the article online, visit http://www.4GuysFromRolla.com/webtech/071800-1.3.shtml

Speed up your ASP pages: Turn Them into HTML with ASPTear!, Part 3

By Evagoras Charalambous


  • Read Part 1
  • Read Part 2

  • In Part 2 we looked at saving the ASP page's output to an HTML file using the FileSystemObject, and in Part 1 we looked at obtaining the ASP page's output using ASPTear. In this, the third and final part, we'll examine how to tie the first two parts together. At the conclusion of this part we'll have our working, high-performance ASP cache engine ready to go!

    Part 3: Putting it all together
    There are many ways and reasons to use transactions for our processing page. The main one is to maintain application integrity, in other words it's an all or nothing deal. Either everything will commit or nothing. If you have a relatively simple page you can use something like this:

    <%TRANSACTION = Required%>
    <HTML>
    <HEAD>
      <TITLE>Processing your request...</TITLE>
    </HEAD>
    
    <BODY>
    <!--#include file="CreateHTMLPage.asp" -->
    <%
      '...do your database updating here
    
      Response.Flush
      Call CreateHTMLPage("/messageboard/default.asp","\messageboard\default.htm")
    
      'Fires if the transaction commits
      Sub OnTransactionCommit
        Server.Transfer("/messageboard/default.htm")
      End Sub
    
      'Fires if the transaction aborts
      Sub OnTransactionAbort
        Response.Write("Your post has not been placed." & VBCrLf)
        Response.Write("An error has occurred. Please try again later" & VBCrLf)
        Response.Write("</BODY></HTML>")
      End Sub
    %>
    

    Please take notice of some things:

      1) In Windows 2000 we need to flush the contents of the processing so the actual update takes place before we ask for the contents of the ASP page. This is not an issue in NT4 as buffering is turned off by default. (If you have turned it on then follow the Win2000 example. If not just add a line after the TRANSACTION directive reading: Response.Buffer = True)

      2) I am using absolute paths whenever possible because it will actually process faster. Relative paths or the familiar technique Server.MapPath(FileName) require an extra trip to the registry.

      3) The arguments of the CreateHTMLPage procedure use different slashes. The first one joins with our web site address to form a complete URL and is therefore different than the Windows/DOS notation of finding a file.

      4) If you using something other than Win2000 then use Response.Redirect(FileName) instead of Server.Transfer which is native to Win2000 and faster.

    Well that's it! Again this is not a solution to all your slow ASP executions, but it could speed them up quite a bit. I used a relatively simple example but one could expand on it. For example if your whole Web site is made up of ASP pages you could change the default document in your "Internet Information Services" or "MS Management Console" to an HTML file first and then to ASP. That way if you create an HTML file using this method it will output that first. Another use of this method could be to process many pages at the same time and combine them... The sky is the limit. Have fun with it and let me know of any questions/comments!

    Evagoras Charalambous
    00229911@bigred.unl.edu


    Attachments:

  • Download the contents of CreateHTMLPage.asp in text format
  • Download the contents of Default.asp in text format


  • Article Information
    Article Title: Speed up your ASP pages: Turn Them into HTML with ASPTear!, Part 3
    Article Author: Evagoras Charalambous
    Published Date: Tuesday, July 18, 2000
    Article URL: http://www.4GuysFromRolla.com/webtech/071800-1.3.shtml


    Copyright 2017 QuinStreet Inc. All Rights Reserved.
    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers