The multisite functionality of Drupal is what I like very much about that system. I run several separate sites as single Drupal multisite configuration.

As far as one may know, drupal multisite functionality is based on separation of databases and files belonging to each site whereas core drupal files, modules and themes may be uploaded once for the whole multisite configuration. This works perfectly because Drupal decides where to read/write files based on HTTP Host header field. Also Drupal connects to appropriate database, configured in corresponding settings.php file for that host.

OK, but what about multisite configuration where Boost cache is used? Luckily, the Boost cache supports multisite setup, too. Though there are some points to keep in mind when running Boost as multisite.

First of all, Boost stores its cache as plain HTML (HTML + .gz) files. Making cached files is not a problem because it is performed by Drupal PHP code. But when fetching data from cache, PHP is not involved at all! Boost caching is based on mod_rewrite rules, specified in .htaccess file which is located in root directory of drupal installation. mod_rewrite rules instruct Apache to return pre-built cached files in response to client requests, if possible. Serving thest cached files instead of running PHP/MySQL/etc stuff on client request is much, very very much faster!

Note, that .htaccess contents must match current Boost configuration (Boost checks .htaccess to warn site admin about inconsistencies).

The problem is that there is only one single .htaccess file shared by all Drupal-powered sites that work as multisite setup. This means that Boost settings that affect .htaccess contents should be the same throughout all sites in a Drupal multisite installation. Since .htaccess is shared by several sites, it must not specify any hardcoded paths to cache data. In fact, cache data is stored by default in separate directories for each HTTP host. Default Boost configuration produces mod_rewrite rules that contain lines like these:

# NORMAL
RewriteCond %{DOCUMENT_ROOT}/cache/normal/%{SERVER_NAME}%{REQUEST_URI}_%{QUERY_STRING}\.html -s
RewriteRule .* cache/normal/%{SERVER_NAME}%{REQUEST_URI}_%{QUERY_STRING}\.html [L,T=text/html]

These rules, as you can see, use SERVER_NAME variable to build cache file path. But sometimes (I’ve noticed that for Hostmonster) you need to specify %{HTTP_HOST} instead of %{SERVER_NAME}. Setting this to HTTP_HOST will use HTTP Host: header to decide where to get cached data:

# NORMAL
RewriteCond %{DOCUMENT_ROOT}/cache/normal/%{HTTP_HOST}%{REQUEST_URI}_%{QUERY_STRING}\.html -s
RewriteRule .* cache/normal/%{HTTP_HOST}%{REQUEST_URI}_%{QUERY_STRING}\.html [L,T=text/html]

Drupal Boost admin page has radiobutton where you can change whis:

Servers URL or Name:
*   %{SERVER_NAME}
(*) %{HTTP_HOST}

So, SERVER_NAME/HTTP_HOST and is the only issue I faced so far running Drupal multisite setup with Boost cache!

  • Print this article!
  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • E-mail this story to a friend!
  • LinkArena
  • LinkedIn
  • MisterWong
  • StumbleUpon
  • Technorati
  • Twitter