If you have a useful feature that works with Boost and it will help others, please add it to this page or add a comment to have it rolled into the page.
- Refresh pages with rules and PHP
- Using Boost with Authcache
- Dynamically load the who's online block
- Drush integration with Boost
- Apache mirror using rsync and Boost
- Including dynamic blocks in a static page
- Boost and Ubercart
Using rules and PHP to refresh changed pages in cache
Case: The website has mostly anonymous visitors and a few content changes every so often. Waiting on cron to run may not be the best solution if you want changes to be available for anonymous visitors immediately. On a website such as this you are taking advantage of the Boost timestamp function to rebuild only pages that have changed at each cron run. This Rules-PHP-Trick works hand in hand with that Boost function as it will immediately refresh the cache with the one page that has has changed, rather than rebuild the entire cache.
Enable this Boost function:
[X] Check database timestamps for any site changes. Only if there's been a change will boost flush the expired content on cron.
Solution: Download the rules module, unzip it and upload it to sites/all/modules. Goto: (Administer > Site building > Modules > List) to enable Rules and PHP filter, save the changes. Goto: (Administer > Rules > Triggered rules > Add a new rule). Give the new rule a label or name, choose an Event that will trigger the rule from the select list (Content is going to be saved), check mark the box [X] This rule is active and should be evaluated when the associated event occurs. and save the changes. In the next section, choose (Add an action). Use the select list and choose (Execute custom PHP code), click next. Add the following code in the PHP Code text box and click save. Note: The PHP delimiters
<?php and ?>are not needed.
global $base_root, $base_path;
drupal_http_request($base_root . $base_path . 'cron.php');
Now each time you create or update a page and save it, a cron run is called and will refresh the cache with the one page that has been changed. Your website visitors will see the new page immediately. A really neat feature!
Using Boost with latest version of Authcache
Case: There is a slight chance Boost will not work with latest version of Authcache.
solution:To get around this issue.
In Boost advanced settings, disable this setting:
[ ] Asynchronous Opperation: output HTML, close connection, then store static file.
I "borrowed" some code from authcache, so we now use the same output buffer hooking mechanism; Boost's is more "Aggressive" though. It sends the page to the browser & closes the connection, then saves it to the disk, allowing for a more responsive site when using boost. With this change, the end game has to be something like the proposed hook_alter_html module; one that all page caching modules can use; thus preventing interference, and improving performance when using multiple page caching solutions.
Dynamically load the who's online block
Case: For sites that like to use a cache to serve the full page (boost, Drupal core cache, ect...), but still would like to have more dynamic content in a block; loading of blocks via ajax is a good way to accomplish this.
Solution: The simple way to do it, for one or 2 blocks it works. For anything more then that it would probably have a negative impact since it's doing a full bootstrap for each block.
More information and examples on this, see this page on Drupal Groups
$block = module_invoke('user', 'block', 'view', 3);
Place this HTML in a new block
Drush integration with Boost
Case: I need to run cron twice hourly (large amount of aggregated content). This becomes problematic with a one hour cache lifetime. If an expired cache clear was integrated into Drush, this would facilitate a periodic cron job to clear the stale files.
Solution: Project provision_boost
From the project page:
The provision boost module provides Drush hooks to automatically setup multi-site Drupal instances (or single sites) with the Boost module. It takes care of all the nitty-gritty configuration fixes that need to be applied in the backend so it works.
Additional cron modules that may help:
Serve cached pages from an Apache mirror using rsync
This useful to run a small server cluster or a mirror. Boost will run as normal on the host server and the cache will be regularly transferred by rsync to the mirror(s). The Boost cache will be served using the boost .htaccess copied to the mirror.
Setup the host server:
Configure rsync at /etc/rsync.conf and add this to the file:
max connections = 1
log file = /var/log/rsync.log
timeout = 300
comment = boost cache
path = /var/www/example.com/cache/normal/example.com
read only = yes
list = no
uid = nobody
gid = nogroup
Set up the mirror server:
It's good to start with a full copy of the cache directory and the Boost htaccess file. Just copy it to the mirror server in the root folder.
Set to crontab to run regularly with:
/usr/bin/rsync -aqz --delete rsync://drupal.server.example.com/example-cache /var/www/example.mirror/cache/normal/example.com/
If you want other stuff running on the mirror, a virtual host will work to separate the requests and serve the cached content if it exists and the user is anonymous, add a proxy to override the virtual host for the other content.
Allow from all
ProxyPass /index.php http://drupal.server.example.com/index.php
ProxyPassReverse /index.php http://drupal.server.example.com/index.php
Including dynamic blocks in a static page
Boost and Ubercart
Since Boost 6.x-1.20, the boost settings has an option to "DISABLE Exit () inside of Boost _exit." This may help in some cases where the 'add to cart' fails.
We need more feedback/testing to determine whether we should make this a default option when Ubercart is enabled.