APGen Documentation Previous Topic: Web Site Optimization Techniques Next Topic: Two-Phase Content Generation Parent Topic: Web Site Optimization Techniques    Web Site Optimization Techniques
Static Page Generation
See Also:

Of all the optimization techniques, static page generation provides the highest level of performance.

Definition

Static page generation involves running an APG script that generates a static web page (.htm or .html).

Advantages

Static pages are by far the most reliable and highest-performing pages.  They are very reliable because they have no server-side code that can break, and they are high-performance because IIS and Windows 2000 have been highly optimized to serve static pages efficiently.  In our testing, a 4 processor x 550 MHz web server with 1 GB of RAM can serve close to 5000 static pages per second, bandwidth permitting.  A 100Mbit (non-switched) network can limit the web server to 1500-2500 pages per second, depending on the size of the page.

Another advantage of static pages is that they are ideal for caching and content distribution, with no extra work.  High-traffic sites should use distributed caching/content distribution to offer users the best response times and alleviate bottlenecks.  Most caching and content distribution systems have agents that monitor the web server's file system for changes.  When pages are generated by APGen, these agents can automatically refresh the distributed caches.  This provides the best performance and always fresh content.  For more information, see Replication.

It is interesting to note that IIS 5.0 currently offers the best performance of any web server for static pages.  IIS 5.0 achieves this performance by using a Sockets API extension named TransmitFileTransmitFile transfers data from the hard drive cache directly to the socket without leaving Kernel Mode.  Most web servers make multiple Kernel Mode to User Mode transitions while copying files to a socket, which slows them down.

Active Page Generator is ideal for generating static pages and taking advantage of their outstanding performance and reliability.  If the content of a page changes less often than it is viewed, and the page has no user-dependent content, it is a good candidate for static page generation.

Disadvantages

While static pages offer the very best performance, they sometimes won't work for production sites due to dynamic ads, storing user IDs in URLs (to support cookieless browsers), and other reasons.  Dynamic ads and URL munging can be implemented using ISAPI filters, so static pages can still be used.  These issues should be considered when designing and implementing a site.  Since static pages do not work well for all situations, consider other techniques like two-phase content generation and page fragment caching for pages with some dynamic content.

How to Generate a Static Web Page

To generate a static page, write an APG script that specifies an output file name with a static extension (.htm or .html), and don’t include any ASP code in the page’s content:

<%#
Output.Filename = "default.htm"
. . .
#%><HTML><HEAD>. . .

After the APG script is written, it must be executed when its data changes.  For more information, see Executing APG Scripts.

The APGen example ASPToAPG is useful for converting existing ASP pages to APG scripts that generate static pages.  For more information, see the Examples topic.