dynamic.pod - dynamic article generation for BSE.


The 0.15 series of BSE from 0.15_19 on, stable around 0.15_28, added the ability for articles to be generated upon presentation to the user.


There are four ways an article can be set to be dynamically generated:

Access controls

BSE 0.15_21 added the ability to restrict siteuser access to articles based on their membership in a group. Articles inherit these access controls from their parent articles if they have the Inherit Parent groups flag set.

If an article has an group requirements, either set on the article itself or inherited from an ancestor article, then that article will be generated dynamically.

Always Dynamic flag

If you set the Always dynamic flag on an article then that article is generated dynamically.

Inherited Always Dynamic flag

If you set the Always dynamic and Descendants inherit Always Dynamic flags on an article then that article and all of its descendants (not stepchildren) will be generated dynamically.

Via bse.cfg

If you set the all_dynamic key in the [basic] section of bse.cfg to a non-zero value then all articles will be generated automatically.

Note: you will need to perform web server configuration to point requests for at, and similarly for the RSS article, otherwise the user will not see generated content for these articles. See Fixed Links below.


Dynamic articles are processing in 2 stages:

  1. static tag replacement - at this point all of the normal static page tags are replaced. The resulting template is saved to the dynamic cache.

  2. dynamic tag replacement - tags specific to dynamic generation are replaced at this point, and the article is sent to the user.

Static tag replacement

This is the same as tag replacement for a static page, except:

Depending on configuration, this can be done either during normal site/article regeneration or just prior to displaying the page. See Just in time processing.

Dynamic tag replacement

Dynamic tags are replaced and the page presented to the user.

The content type sent to the browser is based on the original template of the article, so you can set a key to give your template a different type from text/html but setting it in the [template types] section of bse.cfg.

This is done by the script.

Just in time processing

Normally when you regenerate a dynamically generated article BSE will perform the first pass immediately and save that to the dynamic cache. If your site is large and you do a full site regen this can be very time consuming.

If you set jit_dynamic_regen in [basic] in bse.cfg, then attempting to regenerate the page (including the regen normally done on saving an article) will instead simply delete the pregenerated page from the dynamic cache.

Then when the user attempts to display the page, will notice the missing page, pregenerate it and store it in the cache, and then proceed to normal dynamic page processing.

This means for large sites that you're only generating the pages that users are actually looking at.

Note that if a large percentage of your site is looked at in a day you're probably better off not using this option, since it will increase the load on your web server instead of reducing it.

If your web server normally suffers from high peak-time loads, you should probably not use this, since it moves most page processing to peak-time.


All normal dynamic tags are available during dynamic tag processing, including:

The following tags are available on all user side dynamic pages (search page, shop pages, etc):

The following tags can be used on dynamically generated article pages (as per

There are no dynamic tags specific to catalogs, products or seminars at this point.


Two Pass Generation

Since dynamic pages are generated in two passes a single tag cannot rely upon tags from the two separate passes.

For example:

  if Or [ifUser] [ifAdmin]

won't work because ifUser is a dynamic tag and ifAdmin is a static tag.

Fixed Links

Some articles, like article 1, the home page, and article 3 the main shop article have protected links, by having an entry in the [protect link] section of bse.cfg.

If these articles become dynamic by any of the mechanisms listed in MAKING ARTICLES DYNAMIC then links to these articles will be broken.

For all articles except the home page article you can remove these entries, and your site will work again.

The home page article will need extra web server configuration, you will need to add a rewrite rule to redirect to or whatever other tool your web server provides with the same functionality.


There are 2 ways to run as persistent servers, to reduce startup cost: and Apache::Registry

This has the severe limitation that you can only run one per Apache server, due to limitations in BSE.

To configure Apache to run via mod_perl, add the following to your virtual host configuration:

  PerlModule Apache::Registry
  <Location /cgi-bin/>
    SetHandler perl-script
    PerlHandler Apache::Registry
    Options ExecCGI

page.fcgi and FastCGI

You will need to configure Apache to use mod_fastcgi.

First, Apache needs to be configured to use FastCGI, you may need to install it from source, then configure it:

  LoadModule fastcgi_module /usr/lib/apache/1.3/

Then configure your vhosts cgi-bin directory to run .fcgi scripts with fastcgi:

  <Directory /var/www/httpd/bsetest/cgi-bin/>
    AllowOverride All
    AddHandler fastcgi-script fcgi

Check this works with:

Then setup a rewrite rule:

  RewriteRule ^/cgi-bin/*) /cgi-bin/page.fcgi$1 [PT]


This sets a native mod_perl hander to process requests:

First, let perl know where the BSE libraries are:

    use lib '/yourpath/cgi-bin/modules';

Now load the module, and set it as the handler for

  PerlModule BSE::Handler::Page;
  <Location /cgi-bin/>
    PerlSetVar BSEConfig /var/www/httpd/bsetest/cgi-bin/
    SetHandler perl-script
    PerlHandler BSE::Handler::Page
    Options ExecCGI

The PerlSetVar line should set BSEConfig to the directory containing your bse.cfg file, not to the file itself.


Tony Cook <>