Look ma! No PHP!
Sun Oct 17th 2004, 7:26pm
If you look closely you'll see all pages at The Elk are now pure, straight-up, and (hopefully) fast HTML. No more slow, PHP-rendered web pages! Yay!

It's pretty obvious that rendering every web page at every viewing is inefficient and wasteful--especially for a site that doesn't even provide dynamic content. Every viewer sees the exact same thing, so why render it every time? Well, it was simpler in the beginning to write it that way... A performance nightmare, the previous approach would query the database for the requested article and render the HTML, every time. And the worst offense about it was the "Articles" listing to the left, which caused a full table scan of the database and an entire pull of every article to generate the nice listing you see.

Given how slow my web hosting provider has been lately, I was motivated to change this. Of course, the more sane route might have been to look for a new provider. But not me.

So I've converted the site into a cache of static HTML pages, and a cached article list for the left bar. Of course, I still use PHP behind the scenes to do all of this, for example you'll see .php pages when you post a comment. On the back end, I wrote a cache manager to handle all the issues with cache consistency--the portions of the cache needing an update are regenerated whenever something changes, e.g. a comment is posted, or an article is added. Overall, it was a bit of work to do it this way, but the end result is much cleaner and more efficient. I don't have any hard performance metrics, but overall it does seem a little snappier.



Visitor comments
On Mon Apr 26th 2010, 9:34am, Visitor posted:
jkl