Lang Forge is designed for performance with built-in caching at multiple levels.
In-Memory Translation Cache
php
// First call: 1 DB query (fetches entire translation group)
$translations = lf_get_post_translations(42);
// Second call for any post in the same group: 0 DB queries
$translations = lf_get_post_translations(99); // post #99 is in same group as #42String Translation Preloading
php
// First __() call for English: 1 DB query loads ALL English strings
echo __('Hello', 'theme');
// All subsequent calls: 0 DB queries
echo __('Goodbye', 'theme');
echo __('Contact', 'theme');
// ... (zero additional queries no matter how many strings)Benchmarks
Typical query counts on a site with 3 languages and 500 posts per language:
| Page Type | Without Lang Forge | With Lang Forge | Difference |
|---|---|---|---|
| Single post | 20 queries | 22 queries | +2 |
| Archive (10 posts) | 25 queries | 28 queries | +3 |
| Front page with switcher | 18 queries | 21 queries | +3 |
| String-heavy page (50 strings) | 15 queries | 16 queries | +1 |
Performance Tips
- Use a persistent object cache. Redis or Memcached dramatically reduces database load.
- Preload translations in custom loops. Call
lf_get_post_translations()before entering your display loop.
- Use auto-registration. Add your theme’s text domain to the auto-registration settings. Standard
__()with auto-registration handles string detection automatically.
- Minimize secondary queries. Let Lang Forge handle the main query filtering.
- Use page caching. Full-page caching eliminates nearly all performance overhead.
- Optimize the postmeta table. For sites with more than 50,000 posts:
sql
ALTER TABLE wp_postmeta ADD INDEX idx_lf_language (meta_key(20), meta_value(10));—