Cache Translation Object
A WordPress plugin
This plugin is currently not maintained and has not been tested for a few WordPress releases. I will update it eventually, but for now use with caution!
Substantially increase performance of localized WordPress by caching the translation (l10n) object. Supports multiple languages.
On every pageload a localized WordPress site spends a huge amount of time setting up the translation (l10n) object. Startup for a localized site can be almost four times slower than an untranslated one.
This plugin stores the translation object between pageloads so it only has to be created once, resulting in significantly better performance (performance graph included with screenshot).
Plugin supports caching multiple languages (if you use a multi-language plugin).
Available storage: Plain file, APC (Alternative PHP Cache), or SHMOP (Shared Memory)
You can always find the latest version to download here.
- Download and extract plugin files to a folder in your wp-content/plugin directory.
- Activate the plugin through the WordPress admin interface.
- Select an available storage on options page (see FAQ for more details if necessary).
- File storage needs write permissions (once) to
wp-contentafter install to set up the directory used for storage (
wp-content/cache/l10n-cache). Once set up is finished
wp-contentshould be kept write protected.
Requires at least WordPress 2.8, tested up to WordPress 2.8.5.
Multiple WordPress sites on same host
APC and SHM is a shared storage. This means all sites on host using these storages types will share the same cached objects. If not all sites use the same WordPress version and plugins that is a problem. Different locales are stored as separate objects so is not an issue.
If sites differ please use file storage which store objects in a separate directories for each installation.
- What storage is fastest?
The exact numbers will depend on your configuration but in my testing APC is a tiny bit faster than shared memory which is a bit faster than plain file storage. Take a look at the graph above.
- What is APC (Alternative PHP Cache)?
“The Alternative PHP Cache (APC) is a free and open opcode cache for PHP. Its goal is to provide a free, open, and robust framework for caching and optimizing PHP intermediate code.” It is not usually installed with PHP by default.
- What is SHMOP (Shared Memory)?
It is a PHP interface to handle Unix shared memory segments. It should be available by default on Linux/Unix servers. On Windows it may be possible to enable in PHP.ini. On some older systems (and Windows) shared memory may have problems if multiple languages are used on same site. (If `Open slots` in the debug storage information keeps decreasing you should choose a different storage type.)
- How do I make the file writable?
File storage write files to
wp-config/cache/l10n-cache/. These directories will be created automatically if
wp-configis writable at first use. Once these sub-directories are created
wp-configshould be kept write protected.
- I want to change where the file is written
Currently you’ll have to do it by hand. Find the define at the top of
- Version 1.1
- Rewritten to cache multiple locales separately
- Split out admin functions into separate file
- Handle old SHM with questionable delete behaviour by relocating as necessary.
- Add storage debug info link
- Do not default to any specific storage type, make user choose
- Tell admin when something is wrong (also better error handling).
- Added plugin localization
- Added Swedish translation
- Version 1.0
- Initial release