Update: I've decided to work on this again and re-release it. It should now work fine with Concrete5's built in caching enabled and without having to change your stylesheets to be directly linked in. It also has some other critical bugs fixed, in particular file downloads work correctly now.
It is still very experimental, so use with caution.
I’m a big fan of Concrete5. The system is incredibly powerful, flexible, easy to develop and most of all easy for end users. However, it can at times be a little ‘heavy’ on a server, so I looked into a way to add a lightweight cache around it. Many sites are really quite static, so this cache addition is designed to try to make Concrete5 as ‘static’ in performance as possible.
I based the cache policy on the following thinking:
First download and unzip the file at the end of this post. Drop into the libraries folder of the root level of the Concrete5 site the bootstrapcache folder.
Edit dispatcher.php in the /concrete folder:
Add in the line:
include('libraries/bootstrapcache/bootstrapcache.php');
just after:
Events::fire('on_page_view', $c, $u);
At this stage, the cache should already be working, but you can turn on a debug option to check this:
The default config works fine, but I’ve set it up to look in site.php for config items. Through the config, caching can be enabled/disabled, debug mode switched on, the default cache time set, pages added to an exclude list, or pages added to a list where they have custom cache times. If you do add excluded pages, make sure you still specify the two login pages that need to be in that list. So add to the normal site.php config file items from the following:
// caching switch
define('BOOTSTRAPCACHE', true);
define('BOOTSTRAPCACHE_DEBUG', true);
// if we want to have a different cache time for a specific page
// specify it here, eg:
define('BOOTSTRAPCACHE_CACHE_TIME_SPECIFICS', serialize(array(
'/weather/'=>600
)));Some caveats
I hope someone finds this useful. For me it makes a few sites start to feel like static sites, which is a good thing!
Updates made: 16/05/2011 - change to the way files are identified, fixes to excluded pages handling. The below file has been updated.
Updates made: 12/12/2011 - fix for 5.4.2.2 - any file or script that is accessed through a path that includes 'index.php' (such as file downloads and certain javascript files) is excluded from caching. Change to names used to reference cache file to be more specific. Removed dispatcher.php file from zip - now simply includes instruction on what to edit in the file.
Changes for 5.5.x: this concept was originally for 5.4.x. It does work with 5.5.x, but the instructions had to change a bit. It's still a work in progress.
Download bootstrapcache_for_concrete5.zip