CacheCracker Extension

CacheCracker is an extension to give you complete control over caching in your ExpressionEngine system. It is designed to be installed at any time, including when first starting development on a new project, giving development and your production site a potentially massive speed boost.

Features

CacheCracker has the following features:

CacheCracker Documentation

Functionality

Global

Settings

The following settings are applied globally to CacheCracker.

SettingDescription
Turn on CacheCracker?Set to Yes to enable CacheCracker. Set to No to disable CacheCracker and disable caching for all templates on the site.

Forced Caching

Forced caching is designed to allow you to quickly setup global cache settings for all of the templates on your site. You can also optionally select only specific template groups to force caching on. It's a good idea to turn on this setting when first setting up a new site, to make sure that all newly created templates are automatically cached with your global settings.

If you do not want to cache certain templates, you can use a combination of the Force caching for template groups option and the normal Design > Templates > Template Preferences manager to turn on caching only for individual templates.

We recommend keeping templates that cannot be cached in a common group or groups so all other templates can be more easily cached. Normally, for instance, you would not want to cache a forms template group or a account template group since these contain information specific to a session or user.

Settings

These settings control how the Forced Caching feature of CacheCracker works.

SettingDescription
Force cachingSet to Yes to turn on the forced caching feature.
Forced refresh time (minutes)Default value to set as the refresh timeout for all templates. The default value for this setting is 5256000, which is the number of minutes in 10 years. Note that sites with active content or templates will not really have their templates cached this long.
Force caching for template groupsTemplate groups to force caching for. Defaults to "all". Select the groups you would like to force the above settings to be applied to automatically. On each page load, these settings will be reapplied to the selected groups.

Expire on Editing Templates

Cache files can be automatically reset when templates are edited in the filesystem. ExpressionEngine does not by default reset cache files when template files are edited.

Settings

These settings control how CacheCracker expires caches when editing templates.

SettingDescription
Expire caches when editing a templateSet to Yes to enable this feature.
Template checks only in debug modeSet to Yes to only check for template changes when the DEBUG config value is not 0. Recommended to avoid a small performance penalty on production sites that will not have their templates edited.

Expire on Content Publish

This feature automatically resets cache files when needed to immediately show published content on the live site. It is recommended that you make use of the Channel Settings options to only clear the templates that actually make use of specific channel data. You can also have all cache files reset on every publish, however this will drastically reduce the performance of your site when editing content.

Settings

These settings control how CacheCracker expires caches when publishing content through the control panel.

SettingDescription
Expire caches when publishing contentSet to Yes to enable this feature.
Expire all caches on every publish (ignore channel settings)Forced all cache files to be reset when any content is published.
Channel SettingsAllows you to select - for each channel - which templates in each template group to reset when content is published in that channel.

Shared Global Caching

By default, ExpressionEngine always runs each embed template for each URL on the site, and caches the results only for that URL. This is a huge performance issue with complex headers, footers, menus, or other embedded templates that are identical (or nearly identical) on every execution.

Shared Global Caching automatically copies or symlinks these cached results into all other pages that make use of them to prevent these expensive embeds from running more than once.

When using this option you must use complex conditionals on most global variables, otherwise the results of the conditional will be cached, which is likely not what you want.

One easy way to make a conditional "complex" is simply to place parenthesis around it's expression, like so:

{if (segment_1 == 'about-us')}
    ...
{/if}

If you would like to use segment or global variables in template output, see the next section for Late Global Parsing.

Activating

Settings

This setting allows you to control how template caches are stored.

SettingDescription
Use symlinks for global template cachesUses symlinks instead of copies of shared cache files. This can reduce disk use somewhat, although it does not work correctly on all systems.

Note that leaving this option off uses exactly the same amount of space as normal ExpressionEngine caching, so it is not by any means necessary to use symlinks if normal caching's disk usage is acceptable.

Late Global Parsing

Normally, segment variables, members vars and other globals are stored in the cached version of a page and are not re-parsed. Using this new syntax allows you to use these variables in cached templates and still get the current value substituted, rather than whatever the value was when the template originally ran.

Mainly used in combination with the Shared Global Caching feature, this feature provides a new syntax that allows global variables to be used in output of cached templates.

The new syntax has this format:

{#variable_name#}

This feature requires the free Wallace extension.

Settings

These settings allow you to control CacheCracker's late global parsing feature.

SettingDescription
Add late global vars parsingTurns on this feature.
Exclude late parsing for variables with these prefixesExclude certain groups of variables to increase performance when they are not needed for late substitution. On a site with many pages, you may want to add at least the page_url: prefix to be ignored if you are using Wyvern.

Optional Core Hack

The optional core hack can be applied to fix issues when using caching in combination with the Structure or Uhura modules. These modules modify the segments array used by EE to create cache directories for each URL. Because of this, two issues can arise:

Applying the core hack is easy, simply follow these steps:

  1. Find the file system/expressionengine/libraries/Core.php.
  2. Find the line that looks like this (in version 2.5.0 of EE, this is on line 628):
    require APPPATH.'libraries/Template.php';
    
  3. Replace this entire line with the following lines:
    // BEGIN CacheCracker modification
        require_once PATH_THIRD.'cache_cracker/libraries/CC_Template.php';
        $this->EE->TMPL = new CC_Template();
    // END CacheCracker modificiation
    
  4. Important: After applying the core hack, you must test your site throughly to confirm that all is well.