Support Log in

43. Performance Considerations

Developer Guide
Prefer video? Watch the Lang Forge tutorials 9 short guides covering every feature Watch

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 #42

String 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 TypeWithout Lang ForgeWith Lang ForgeDifference
Single post20 queries22 queries+2
Archive (10 posts)25 queries28 queries+3
Front page with switcher18 queries21 queries+3
String-heavy page (50 strings)15 queries16 queries+1

Performance Tips

  1. Use a persistent object cache. Redis or Memcached dramatically reduces database load.
  1. Preload translations in custom loops. Call lf_get_post_translations() before entering your display loop.
  1. Use auto-registration. Add your theme’s text domain to the auto-registration settings. Standard __() with auto-registration handles string detection automatically.
  1. Minimize secondary queries. Let Lang Forge handle the main query filtering.
  1. Use page caching. Full-page caching eliminates nearly all performance overhead.
  1. 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));

Forge AI Assistant Online

Hi! I'm the Lang Forge AI assistant. Ask me anything about the plugin — setup, features, troubleshooting, or development.

Just now
Powered by Forge AI · Browse docs