Static Content for WordPress

Via Matt's Aside, Bill Zeller has produced a static files generation plugin for WordPress! It is a great news for me, who has got WordPress running with 3 content filter plugins on this wimpy 400Mhz web server. An index page with 15 blog entries would take 1.5 seconds to manufacture, and my yearly archive pages would make the server crawl for a good 5 seconds. Here's my benchmark with Staticize:

URI Dynamic Static
(Index page)
1.194 sec 0.002 sec
(Yearly archive)
6.449 sec 0.003 sec
(Monthly archive)
4.822 sec 0.004 sec
(Individual archive)
0.261 sec 0.001 sec

As you can see, serving static content has substantial performance gain comparing to serving pages dynamically. I am a happy man :)

I was wondering how the content synchronisation issue is managed, which is probably the trickiest part of all cache implementations. By looking at the source code, it appears that the full HTML content are cached on a per-URI level into individual files on disk. If there is any action triggered, i.e. entries added/modified, comments added, etc, all cache files are removed from the directory. Depending on how fast the file system is, and how many entries are there, it can probably be a slow process.

Staticize would also affect some content filter plugins which might not always proudce the same result from the same content. As Brad Froehle has pointed out, Search Hilite plugin would not work. But I guess it would be fine with me. It would not work with pages that have sourced dynamic contents from else where, i.e. external blog roll files, etc. But since I don't use it that's okay for me as well.

Update: Some fixes to get it to better work with mod_rewrite, when REQUEST_URI is no longer just the script name with parameters but crafted URL. Without it, my redirect script for converting my old Movable Type URL would no longer work. That is an issue with Staticize plugin - it only replays the content but it does not replays the header. I might look at that later...

@@ -37,7 +37,7 @@   
-    $key = $_SERVER["REQUEST_URI"];
+    $key = $_SERVER["SCRIPT_NAME"];
     if(strpos($key, 'wp-') !== FALSE)
         $isAcceptable = FALSE;
@@ -54,6 +54,7 @@
             return;     } 
+   $key = $_SERVER["REQUEST_URI"]; 
    $staticFileName = md5($key).'.txt';

Update 2: Another annoyance. As I have previously stated, dynamically generated content that gives different C' when the same C is given, Staticize would not be able to help. I have just encountered another case this morning - the 'Edit' button! When an author visited the site, i.e. me, an 'Edit' button is supposed to be generated next to the article so I can easily click on it and make modifications. Not So if the content with the 'Edit' has already been cached! Even worse, it would be possible for content with the 'Edit' button to be cached that everyone would be able to see.

Nothing is perfect.

Update 3: WordPress automatically filled out the comment form, which can be cached by Staticize! I guess it makes more sense to hack Staticize to regex replace some contents before spilling out the cache.