Kolab webclient caches

Kolab webclient (Roundcube together with set of Kolab plugins) does cache some data for better performance. There are a few types of cache. I’ll try to explain what we have there and how you can configure the cache for your needs.

IMAP indexes and folders metadata

In this cache we store folders lists, message counts, message indexes and folders METADATA (folder types, colors, identifiers, etc.). This is a general purpose cache so other components can use it too. For example if configured in this cache will land also lists of LDAP groups, LDAP config information (vlv), uploaded attachments, contact birthday calendar, folders ACL, authentication username canonification maps, etc.

It can be configured to use sql database, memcache or apc. Here’s a list of main configuration options (/etc/roundcubemail/config.inc.php):

// Type of IMAP indexes cache. Supported values: 'db', 'apc' and 'memcache'.
$config['imap_cache'] = null;

// Lifetime of IMAP indexes cache entries. Possible units: s, m, h, d, w
// Note: most of this cache data is re-set when user logs into webmail
$config['imap_cache_ttl'] = '10d';

// Type of LDAP cache. Supported values: 'db', 'apc' and 'memcache'.
$config['ldap_cache'] = 'db';

// Lifetime of LDAP cache entries. Possible units: s, m, h, d, w
$config['ldap_cache_ttl'] = '10m';

As this is a part of Roundcube Framework all caches are used by other Kolab components: iRony, Chwala, Syncroton.

// Enables caching of some SeaFile information e.g. folders list
// Note: 'db', 'apc' and 'memcache' are supported
$config['fileapi_seafile_cache'] = 'db';

// Expiration time of SeaFile cache entries.
$config['fileapi_seafile_cache_ttl'] = '7d';

// Type of ActiveSync cache. Supported values: 'db', 'apc' and 'memcache'.
// Note: This is only for some additional data like timezones mapping.
$config['activesync_cache'] = 'db';

// lifetime of ActiveSync cache
// possible units: s, m, h, d, w
$config['activesync_cache_ttl'] = '1d';

// Type of ActiveSync Auth cache. Supported values: 'db', 'apc' and 'memcache'.
// Note: This is only for username canonification map.
$config['activesync_auth_cache'] = 'db';

// lifetime of ActiveSync Auth cache
// possible units: s, m, h, d, w
$config['activesync_auth_cache_ttl'] = '1d';

iRony uses other file for configuration (/etc/iRony/dav.inc.php):

// Type of Auth cache. Supported values: 'db', 'apc' and 'memcache'.
// Note: This is only for username canonification map.
$config['kolabdav_auth_cache'] = 'db';

// lifetime of the Auth cache, possible units: s, m, h, d, w
$config['kolabdav_auth_cache_ttl'] = '1h';

// Enable caching for LDAP directory data.
// Used when kolabdav_ldap_directory is enabled in iRony
// This is recommended with 'searchonly' => false to speed-up sychronization of multiple clients
$config['kolabdav_ldap_cache'] = 'memcache';
$config['kolabdav_ldap_cache_ttl'] = 600; // in seconds

Mail messages

This cache uses only SQL database. Here we store mail messages and this includes headers, structure, flags and bodies (up to defined size, so this one can be disabled).

// Enables messages cache.
$config['messages_cache'] = false;

// Lifetime of messages cache. Possible units: s, m, h, d, w
$config['messages_cache_ttl'] = '10d';

// Maximum cached message size in kilobytes.
// This is size of all message parts together.
// Set it to 0 if you don't want to store any bodies.
// Note: On MySQL this should be less than (max_allowed_packet - 30%)
$config['messages_cache_threshold'] = 50;

Groupware objects

This cache is managed by libkolab plugin. It also uses SQL database only. Here we store payload of all groupware objects, i.e. complete XML content with some additional information except message headers and attachments. It also contains list of groupware folders with some status data needed for cache synchronization.

This is configured via /etc/roundcubemail/libkolab.inc.php file. Note that while it technically is possible to disable the cache, this is not really supported. Note the kolab_messages_cache_bypass option (see below), which is disabled by default. I recommend to set it to 2 for better performance.

// Enable caching of Kolab objects in local database
$config['kolab_cache'] = true;

// Cache refresh interval (default is 12 hours)
// after this period, cache is forced to synchronize with IMAP
$config['kolab_cache_refresh'] = '12h';

// When kolab_cache is enabled Roundcube's messages cache will be redundant
// when working on kolab folders. Here we can:
// 2 - bypass messages/indexes cache completely
// 1 - bypass only messages, but use index cache
$config['kolab_messages_cache_bypass'] = 0;


There’s a lot of information stored in cache. How the cache is used is another story. Definitely the number of features Kolab webclient provides causes many SQL/memcache traffic. While it’s still better to get the information from cache than from LDAP or IMAP, I’m not saying there’s no room for improvement.

Recently I reviewed the code in this context and found some performance issues that I fixed. From my basic tests the overall performance improvement is up to 20%. And this is without any structural or architectural changes. Merge request is waiting for review here.