Authcache 2 tuning guide - avoid the database
Rendered pages are cached in the database when using the Authcache Builtin Storage Backend module by default. As a result Drupal still needs to access the database when delivering a page from the cache. It is possible to swap out the cache handler with an implementation which is better suited for volatile key-value collections and avoid the database completely when delivering pages from the cache. This helps on cutting back database size and traffic and reduces response times for cache-hits by at least one half.
In Drupal 7 configuration (aka variables) is stored in the database. It follows that when there is no database connection, the configuration will not be available. This means that settings which were customized using administrative pages (e.g. on Administration » Configuration » Development » Performance) will be at their default state when cached pages are delivered. Therefore it is important to hard-code settings which influence cache delivery directly in settings.php.
On sites with a great amount of content, the page cache may grow quite large. Therefore it is necessary to assess storage needs before deciding which cache backend is suitable (e.g. in-memory vs on-disk). When upgrading from the database cache, the size of the current cache can be estimated by inspecting the cache_page table in the database.
Shared settings
// FIXME: Put backend-specific settings here, see the respective sections about Memcache, MongoDB and Redis for suitable fragments.
/**
* When serving cached pages, do not bother connecting to the database.
*/
$conf['authcache_builtin_cache_without_database'] = TRUE;
/**
* All customized settings influencing page delivery need to be set here.
*/
// Deliver gzip compressed pages if possible
$conf['page_compression'] = 1;
// Allow browsers to store the page for up to 10 minutes
$conf['page_cache_maximum_age'] = 600;
/**
* Required configuration for Authcache Builtin Storage Backend.
*/
$conf['cache_backends'][] = 'sites/all/modules/authcache/authcache.cache.inc';
$conf['cache_backends'][] = 'sites/all/modules/authcache/modules/authcache_builtin/authcache_builtin.cache.inc';
Configure Memcache API
This section shows a sample settings.php configuration for the memcache module:
/**
* Use Memcache for the page cache and authcache keys.
*/
$conf['cache_backends'][] = 'sites/all/modules/memcache/memcache.inc';
$conf['cache_class_cache_page'] = 'MemCacheDrupal';
$conf['cache_class_cache_authcache_key'] = 'MemCacheDrupal';
$conf['cache_class_cache_bootstrap'] = 'MemCacheDrupal';
$conf['memcache_servers'] = array('127.0.0.1:11211' => 'default');
// FIXME: Put shared settings here (see above).
Note, Memcache API and Integration up to and including 7.x-1.3 suffers from #2361001: Page cache never expires if authcache_builtin_cache_without_database is enabled. Make sure to install an up-to-date version of the module.
Configure Memcache Storage
This section shows a sample settings.php configuration for the Memcache Storage module:
/**
* Use Memcache Storage for the page cache and authcache keys.
*/
$conf['cache_backends'][] = 'sites/all/modules/memcache_storage/memcache_storage.inc';
$conf['cache_class_cache_page'] = 'MemcacheStorage';
$conf['cache_class_cache_authcache_key'] = 'MemcacheStorage';
$conf['cache_class_cache_bootstrap'] = 'MemcacheStorage';
$conf['memcache_servers'] = array('127.0.0.1:11211' => 'default');
// FIXME: Put shared settings here (see above).
Configure MongoDB
This section shows a sample settings.php configuration for the MongoDB module:
/**
* Use MongoDB for the page cache and authcache keys.
*/
$conf['cache_backends'][] = 'sites/all/modules/mongodb/mongodb_cache/mongodb_cache.inc';
$conf['cache_class_cache_page'] = 'DrupalMongoDBCache';
$conf['cache_class_cache_authcache_key'] = 'DrupalMongoDBCache';
// FIXME: Put shared settings here (see above).
Configure Redis
This section shows a sample settings.php configuration for the Redis module:
/**
* Use Redis for the page cache and authcache keys.
*/
$conf['redis_client_interface'] = 'PhpRedis';
$conf['cache_backends'][] = 'sites/all/modules/redis/redis.autoload.inc';
$conf['cache_class_cache_page'] = 'Redis_Cache';
$conf['cache_class_cache_authcache_key'] = 'Redis_Cache';
// Minimum cache lifetime setting. Not setting $conf['cache_lifetime'] (or some
// custom redis TTL config value) makes Redis set default TTL length which is
// 365 days which makes Redis storage full of keys, with huge expiration
// values. Therefore it shouldn't be left unset.
$conf['cache_lifetime'] = 10800;
// FIXME: Put shared settings here (see above).
Note, Redis 7.x-2.12 suffers from #2354181: Fatal error with $conf['page_cache_without_database'] = TRUE.
Configure File Cache
This section shows a sample settings.php configuration for the File Cache module:
/**
* Use File Cache for the page cache and authcache keys.
*/
$conf['cache_backends'][] = 'sites/all/modules/filecache/filecache.inc';
$conf['filecache_directory'] = '/full/path/to/your/file-cache/directory';
$conf['cache_class_cache_page'] = 'DrupalFileCache';
$conf['cache_class_cache_authcache_key'] = 'DrupalFileCache';
// FIXME: Put shared settings here (see above).
When running on Apache it is not necessary to specify the filecache_directory. However it still might come in handy in multi-site setups like outlined in the file-cache README.txt:
Here is a example of a simple configuration that works for multi-site deployment. conf_path() always returns "sites/SITENAME" and this is used to retrieve SITENAME. File Cache creates directory if it doesn't exist and there should be no problem with permissions since it's in /tmp.
$conf['filecache_directory'] = '/tmp/filecache-' . substr(conf_path(), 6);
Verify the settings
In order to verify whether the settings are picked up, log into the site as an administrator and navigate to Administration » Reports » Status report. There should be a line specifying which cache class is used.
When Authcache Debug is enabled, this information is also visible in the debug widget.
Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion

