cache the language files in one big file (Trac #2877) #2877
Original ticket http://trac.elgg.org/ticket/2877 on 41109860-03-27 by trac user coldtrick, assigned to cash.
Elgg version: 1.7
One of our clients had a lot of performance issues on their Elgg 1.7.1 installation.
We decided to cache the loaded languages in one large file (per language) and this decreased the loading time of pages by 30%-50%.
To test that there is a problem load the core language file 100 times. All the time goes into add_translation, since this is an array merging.
As the languages on a running site don't change (all that much) why not cache them like simplecache.
Attached you'll find a file how we did it on an Elgg 1.7.1 installation. It isn't the nicest code but it should give a direction, and it works.
brettp wrote on 41110567-04-11
Thanks for taking the time to research this. I've attached a patch file for only the changes.
Looking at how you're storing the file, did you find that your method of storing the file by creating actual PHP code is faster than serializing the array?
trac user sembrestels wrote on 42036582-03-31
Each language should be loaded when it is necessary.
Usually only one language per page is needed, sometimes more, when you use the third parameter of elgg_echo, but not all languages per page.
Doing a cache per language and loading it when it is needed will improve performance a lot.
trac user coldtrick wrote on 42038045-08-19
Replying to sembrestels:
As stated in the start of this ticket you should have one file per language.