When you think ASP, think...
Recent Articles
All Articles
ASP.NET Articles
Message Board
Related Web Technologies
User Tips!
Coding Tips

Sample Chapters
Commonly Asked Message Board Questions
JavaScript Tutorials
MSDN Communities Hub
Official Docs
Stump the SQL Guru!
XML Info
Author an Article
ASP ASP.NET ASP FAQs Message Board Feedback
Print this page.
Published: Tuesday, July 18, 2000

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!

    - continued -

    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%>
      <TITLE>Processing your request...</TITLE>
    <!--#include file="CreateHTMLPage.asp" -->
      '...do your database updating here
      Call CreateHTMLPage("/messageboard/default.asp","\messageboard\default.htm")
      'Fires if the transaction commits
      Sub OnTransactionCommit
      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)
      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


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

  • ASP.NET [1.x] [2.0] | ASPFAQs.com | Advertise | Feedback | Author an Article