Improve Performance with Dynamic and Static Pages

The debate between dynamic and static pages is probably one that will go on for all time. If you are a fan of Douglas Adams, and believe that his work represents a possible outcome to the universe, perhaps it will even go on beyond time. If so, order me something if you happen to be dining at the end of the universe.

Nonetheless, it is quite possible that the best possible performance for Movable Type users is actually not dynamic or static, but a combination of the two. The reason being is, quite simply, because there are places that you can make use of both to maximize the benefits that both technologies offer.

The benefit of static pages is simple – the don’t need to run from the database. If you are having any server problems such as slow queries or if your database is offline for any reason, your pages will still be there and your site will still run. Plus, most web servers are optimized to serve static pages much faster than dynamic ones.

As such, your most popular pages should generally be served by static pages. These will almost always be your main index (home page) and your individual page archives. In some cases, you may have other pages that are also popular, such as a feed, but these are dependent on your particular site.

Other pages can often be handled dynamically because while they may have some interest to visitors, they don’t have quite the load as the others. These are usually archive pages, such as category and monthly pages. They don’t usually have quite the same amount of “bling”, either – items like comment count and other widgets that can really drive up the cost of building a page. If for any reason your pages do meet either of these criteria, you may want to consider whether or not you build them dynamically.

Finally, there is also another option – using the Publish Queue. This allows you use the static option, but only irregularly. What will happen is the pages will be submitted to a queue to be built at some point by a scheduled process. For pages that need to be rebuilt, but not constantly, this is perfect. They can simply wait until the worker comes along and then be rebuilt when that time happens – every hour, a couple of times a day or even just once a day when there is nothing else going on (the middle of the night perhaps).

Using these techniques can really make the publishing process on your site move along a lot faster. Judicious use of these processes, as well as caching and includes from the filesystem, can do even more. There usually isn’t a problem with a completely static site if it’s really small. If you have even a moderately-sized site, then you’re going to want to consider how the pieces all fit together!


Posted

in