Static Hybrid Module

10/30/2005 11:18:26
tags: OddMuse, web

Installing a module is easy: Create a modules subdirectory in your data directory, and put the Perl file in there. It will be loaded automatically.

Download module:

This module is a modification of Alex Schröeder’s Static Copy Extension.

The original plugin allowed you to export a copy of your wiki as static HTML pages, without much of the features of the wiki (editing pages, comments, etc). This sped up serving time, but limited the usefullness of the wiki in the first place.

This plugin is designed to combine the best of both worlds. Your site will run just as it usually does, except that pages will be served faster because they are pre-saved as XHTML files. When a visitor edits a page, the cached XHTML file is updated.

You can also use the static action to rebuild all pages within your wiki (You must be an administrator to do this.) You can append an id= bit to the url to update a single page.

Otherwise, it works the same way as the Static Copy Extension and I suggest reading Alex’s description of that module.

Server Requirement

In order for this plugin to make any sense, you need a server that allows you to access to the RewriteEngine in Apache, or something similar:

Here is what I use:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /wiki/wiki.cgi/$1 [L,QSA]

In other words, the URL used to access SomePageName needs to be the same whether it’s served from a static page, or live from the Oddmuse cgi.

Customization

All configuration should be done in your config file.

By customizing your %StaticLinkedPages variable, whenever a given page is updated, other pages will be updated automatically. This is useful for [[Journal Pages]], for example.

%StaticLinkedPages = (
    '^\d\d\d\d\-\d\d\-\d\d' => ['Latest_News',],
);

You can designate certain pages NOT to be cached:

@StaticIgnoredPages = (
    $RCName,
);

(Though with the linked pages feature, there aren’t too many pages that I would NOT want to cache)

Required Configuration

You must set the $StaticDir and $StaticUrl variables.

Limitations

Because pages are cached, any features that are calculated at the time the page is served will not be updated. For example, referrer tracking is useless as most visitors will be missed. Pages that include pages or rss feeds from other sources will not be updated automatically (you must use the static action).

If you have a limited number of pages using these features, simply add them to your @StaticIgnoredPages array, and those pages can still be generated on the fly.

When you create a new page, any pages that had previously pointed to the same page but had an edit link will continue to show the edit link. You should periodically run the static action for your entire site to clean up.

Now that there are linked pages, it can take a while to save a new page if it causes multiple other pages to be updated.

Known Bugs

So Why Should I Use This?

Because your site will be DRAMATICALLY faster, depending on how many pages you have. This will make your visitors happier, and should drastically cut down your impact on your server.

Feel free to browse around this site and pay to attention to how quickly pages are loaded. Even the SiteMap loads quickly, since it is also pre-generated.

Version History

  • 1.10 - Fix code to decide when to update the cluster page

  • 1.9 - Try to minimize updating linked pages when it isn’t necessary. Remove the warn statements I had left during a debug session

  • 1.8 - if you edit a Comment Page, don’t add all linked files, just the page being commented on (to update comment count)

  • 1.7 - fix issue where linkedpages with " " in names would not be updated properly

  • 1.6 - buggy - don’t use

  • 1.5 - fix bug with newly created pages (I think)

  • 1.4 - update clustermap and parent cluster, prevent infinite loops

  • 1.3 - Fix bug with ‘_’ in cluster names

  • 1.2 - Fix EditNearLinks, rather than disable it

  • 1.1 - initialize

Things To Do

Add a “Rebuild this page” option in the administration links?

Similar Pages