5

I'm debugging a slow Wordpress website, and saw this XDebug report from Webgrind:

webgrind report for slow wordpres website

The majority of the processing is done by translation related functions.

I would like to:

  • A) Cache translations so it only runs once, or when triggered by cron
  • B) If caching is not possible, completely disable translation related functions
6
  • I just decreased my loading time from 11s to 8s just by changing my site language from PT-BR to English. It didn't mess my website language, as my theme is custom and the strings are hardcoded without the __() function Commented Feb 5, 2017 at 6:20
  • while translations will cause slower execution, it should not be something you can actually notice. There has to be soething else (which might in someway be related) that goes on. as always, turn off plugins and change theme to see when the problem starts Commented Feb 5, 2017 at 6:32
  • Mark, i'm trying, believe me, but I couldn't find it. Any tips to find it with webgrind? I didn't see anything obviously standing out. Most called function on apply_filters is translate, for example Commented Feb 5, 2017 at 6:40
  • We use this plugin, maybe it's helps you also github.com/inpsyde/translation-cache
    – bueltge
    Commented Feb 8, 2017 at 22:29
  • Just for reference, check this question and code as well: wordpress.stackexchange.com/questions/230686/… Commented Apr 28, 2017 at 1:26

1 Answer 1

1

I answered a similar question on Stack Overflow recently.

Don't forget that the profiler itself adds a big overhead. If your page loads are still really slow with XDebug disabled then I don't think your problems are limited to translation files and you should look at caching entire pages.

You can eliminate MO file loading as a problem by preventing the loading of all translation files. This is easy with just one line:

add_filter('override_load_textdomain', '__return_true');

If this doesn't speed things up then a caching plugin won't either. Caching the MO files will save only the overhead of reading the MO files from disk, and in my experience this is rarely a bottleneck. MO files are binary and so parsing them is fast.

If the parsing really makes a difference (with xdebug off) then perhaps you have slow disk reads and need to look at boosting your hardware. Otherwise the caching plugin already given in the comments would let you use a fast memory cache.

Regardless of how the strings are pulled into memory (or not) every call to the internal translate function via __ and friends will still be executed and do work. There is no way to skip this from happening in the WordPress core or in other plugins where you can't hard code the text.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.