getgrav / grav-plugin-langswitcher

Grav LangSwitcher Plugin
https://getgrav.org
MIT License
28 stars 26 forks source link

3.0 update slows down site #72

Closed replayshot closed 2 years ago

replayshot commented 2 years ago

Hi, I've updated to the latest version of langSwicher (from 2.0.1 to 3.0.1) and my site suddenly became very sluggish.

I noticed that in debugger - debugbar Messages I saw repeated setting of active language. msg

I do have custom twig files that I use, so it could be the issue there. However, I was just wondering if you'd have some insight into why it is happening. Thanks much,

rhukster commented 2 years ago

Version 3.0 has a new 'translate_urls` option that defaults to true. This functionality loops through every language and calculates the 'translated' page URL, so with custom slugs you get proper translated URLs in the lang switcher. However, this does take some time, and the more languages you have, the more impact it has.

In the soon to be released version 3.0.2, this is helped by caching the translated URL's per route, so they only have to calculated per-page for a single language and from that point in, it will use the cache version (until some content is changed, and it needs to recache)

In the meantime, you can always disable this translate_urls option in the langswitcher configuration, and go back to the previous 'untranslated' but faster, behavior.