Author |
Message |
qspy Board Member

Joined: 03 Nov 2009
        Posts: 10

|
Posted: Thu Nov 05, 2009 5:52 am Post subject: template.php to statically write language vars to cache |
|
|
This is theory, not checked it deeply, but i think main_lang.php is scanned a lot to retrieve lang['text'] even from cached template files.
If it is indeed scanned like this, it can cost a lot of php processing time at heavy load especially.
Am i right? Someone made this before? i am missed something?
example cache/tpl_name.index_body.php
Code: | <th width="50" class="thTop" nowrap="nowrap">| <?php echo isset($this->vars['L_TOPICS']) ? $this->vars['L_TOPICS'] : $this->lang('L_TOPICS'); ?>| </th> |
(btw, stupid code wtf , if a = 1 then a = 1 else a = 1)
could be made static:
Code: | <th width="50" class="thTop" nowrap="nowrap">| Topics | </th> |
|
|
Back to top |
|
 |
Acaria Board Member

Joined: 20 Feb 2009
         Posts: 238

|
Posted: Thu Nov 05, 2009 6:44 am Post subject: Re: template.php to statically write language vars to cache |
|
|
I don't think it works that way. I think it's set up so all lang variables can be called from anywhere, like an include hidden somewhere around the code.
Not sure though. Wait for someone like Dog Cow to come in and explain it perfectly in one sentence. XD |
|
Back to top |
|
 |
Ptirhiik Board Member

Joined: 19 Nov 2008
         Posts: 114

|
Posted: Thu Nov 05, 2009 7:38 am Post subject: Re: template.php to statically write language vars to cache |
|
|
Using lang files versus static text serves two purpose : using the same text everywhere for the same object, and allowing the interface to be translated in many languages. It costs more resources (uc/memory) than static texts of course, but the advantage largely justify it : accessing an array with its natural key is pretty straight forward for the php processor, the concern is more the memory consumed in keeping this array during the construction of the page, so it has to remain small, and loaded the later possible. |
|
Back to top |
|
 |
qspy Board Member

Joined: 03 Nov 2009
        Posts: 10

|
Posted: Thu Nov 05, 2009 10:32 pm Post subject: Re: template.php to statically write language vars to cache |
|
|
We need only 1 language, so ... we could do that static, anyone? maybe some point to where start coz i do a lot now (like solving hdd bottleneck). |
|
Back to top |
|
 |
Acaria Board Member

Joined: 20 Feb 2009
         Posts: 238

|
Posted: Fri Nov 06, 2009 12:29 am Post subject: Re: template.php to statically write language vars to cache |
|
|
You'd have to go in and replace every single call to a language file with static text. Considering PhpBB basically uses lang lines for upwards of 80% of all text generated from Php files, you'll be spending a loooong time typing. |
|
Back to top |
|
 |
Dog Cow Board Member

Joined: 18 Nov 2008
         Posts: 378

|
|
Back to top |
|
 |
qspy Board Member

Joined: 03 Nov 2009
        Posts: 10

|
Posted: Fri Nov 06, 2009 9:56 pm Post subject: Re: template.php to statically write language vars to cache |
|
|
Dog Cow wrote: | There are some pit-falls to this method. Not all of the 'L_*' variables are static.
See here: http://www.phpbb.com/community/viewtopic.php?f=16&t=810295 |
True not all, but this speedy templates messing my simple subforums and viewtopic. |
|
Back to top |
|
 |
|