Cut 90% of your WordPress translations loading time

WordPress translations are compiled from human-readable PO-files into machine optimized MO-files, but still takes a lot of overhead to load. If you only could cache the translation load time, you would save a lot of page load time. We can easily cut 90% of our WordPress translations loading time.

Advertisement:

According to my tests, you could actually save 90% of the load time, just by caching the results in a database-saved transient. If you add a proper persistent object-cache backed by Memcache, Redis, or php-apcu you should see a huge speed improvement on that again. I did a few tests here on the “default” textdomain, which showed a 90 % speed gain:

I did some more tests, with both plugins and themes, and they consistently showed a 90% speedup gain of the WordPress translations loading time.

You don’t have to worry about cache purging or using stale translations, as the function checks the file modification time of your translation files, before using the cached version.

The WordPress.org user nicofuma has added a Trac ticket 3 years ago, where it looks like everybody ended on an agreement of merging this into a future release, some 20 months ago. I have no idea why this isn’t in WordPress core yet, but if you want to use this yourself right now, you can add an mu-plugin with the following code from Per Søderlind:


By the way: If you want hassle-free, amazingly fast web hosting, you should check out Servebolt (affiliate link). They’ll even transfer your site for free.


There are 2 comments

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.