Make phpBB faster/liter by replacing dynamic strings with static one
Forum rules
Please do not post support questions regarding installing, updating, or upgrading phpBB 3.3.x. If you need support for phpBB 3.3.x please visit the 3.3.x Support Forum on phpbb.com.
If you have questions regarding writing extensions please post in Extension Writers Discussion to receive proper guidance from our staff and community.
Please do not post support questions regarding installing, updating, or upgrading phpBB 3.3.x. If you need support for phpBB 3.3.x please visit the 3.3.x Support Forum on phpbb.com.
If you have questions regarding writing extensions please post in Extension Writers Discussion to receive proper guidance from our staff and community.
-
- Registered User
- Posts: 5
- Joined: Fri Aug 17, 2012 6:24 am
Make phpBB faster/liter by replacing dynamic strings with static one
Hi everyone! I was just customizing my phpBB's template..when i saw so many dynamic strings that could be made static..The first thing that comes in my mind is by replacing the "U" (Url variable) and "L" (Language variable) variables with the static ones; for example: {U_Search} ----> http://www.websiteurl.com/search.php and: {L_Search} ----> Search. Don't you think that making them static will avoid the template file calling everytime the many variables set in the common file and elsewhere (loading the server more than the necessary too), instead of just "showing" them to the user's browser? We will let Apache "calm down" and make the html work thus LESS SERVER LOAD I know you will say 'yeah but everyone needs to set his own static variable according to his website's url and language'...well..you can simply make a php form that modifies all the variables in the template files (or elsewhere) given the website's url that is inserted into the textfield, and for the language are taken from a preexisting language file so what do you think about it?
-
- Registered User
- Posts: 5
- Joined: Fri Aug 17, 2012 6:24 am
Re: Make phpBB faster/liter by replacing dynamic strings with static one
Nobody? at least..can someone tell me if i should do this or not?
Re: Make phpBB faster/liter by replacing dynamic strings with static one
Don't you think they're variables for a reason?
Above message may contain errors in grammar, spelling or wrongly chosen words. This is because I'm not a native speaker. My apologies in advance.
-
- Registered User
- Posts: 5
- Joined: Fri Aug 17, 2012 6:24 am
Re: Make phpBB faster/liter by replacing dynamic strings with static one
Yes, but once you are ready to make that forum live (and also before) variables/strings such as "{U_SEARCH}" and "{U_LOGIN}" for example will most likely remain fixed/unchanged...tell me..why in the world should you change the search url (one in the middle of the jungle of the other potential static strings of course)? I've already tried to and i saw an improvement in the CPU usage and the page's loading time
- imkingdavid
- Registered User
- Posts: 1050
- Joined: Thu Jul 30, 2009 12:06 pm
Re: Make phpBB faster/liter by replacing dynamic strings with static one
Well, for one thing, if you have multi-lingual users, you will not be able to take advantage of language packs if you hardcode the text into the template. Also, if you ever decide to change a string of text, and it appears in multiple locations, it is significantly more work to change it everywhere it appears than to simply change the language string in a single file.
One reason links are not hardcoded, aside from a similar reason above (not having to change multiple uses of the same link multiple times), internal links are passed through append_sid() so that the session is always sure to be kept. If you hardcode the links, in some cases your users may lose their session and have to re-login, which is an inconvenience for them.
In any case, keep in mind that if you hardcode all these links and URLs in your template, you will have a difficult time updating because the automatic updater will not know how to handle all of that, so you will have to do it manually.
I doubt that any speed increase brought about by removing template variables is significant enough to justify such a major change.
One reason links are not hardcoded, aside from a similar reason above (not having to change multiple uses of the same link multiple times), internal links are passed through append_sid() so that the session is always sure to be kept. If you hardcode the links, in some cases your users may lose their session and have to re-login, which is an inconvenience for them.
In any case, keep in mind that if you hardcode all these links and URLs in your template, you will have a difficult time updating because the automatic updater will not know how to handle all of that, so you will have to do it manually.
I doubt that any speed increase brought about by removing template variables is significant enough to justify such a major change.
- callumacrae
- Former Team Member
- Posts: 1046
- Joined: Tue Apr 27, 2010 9:37 am
- Location: England
- Contact:
Re: Make phpBB faster/liter by replacing dynamic strings with static one
It's a negligible performance gain, in my opinion.
-
- Registered User
- Posts: 5
- Joined: Fri Aug 17, 2012 6:24 am
Re: Make phpBB faster/liter by replacing dynamic strings with static one
That wouldn't be a problem; you don't need to edit every string by hand one by one..you could make a php file with a str_replace function just to say one. You're right 'if you ever decide' no one would be so insane to go changing a string every now and then..the only reasons can be if you change domain/folder. But anyway the work is done one time, and not everytime like when the pages are loaded, get it?imkingdavid wrote:Well, for one thing, if you have multi-lingual users, you will not be able to take advantage of language packs if you hardcode the text into the template. Also, if you ever decide to change a string of text, and it appears in multiple locations, it is significantly more work to change it everywhere it appears than to simply change the language string in a single file.
One reason links are not hardcoded, aside from a similar reason above (not having to change multiple uses of the same link multiple times), internal links are passed through append_sid() so that the session is always sure to be kept. If you hardcode the links, in some cases your users may lose their session and have to re-login, which is an inconvenience for them.
In any case, keep in mind that if you hardcode all these links and URLs in your template, you will have a difficult time updating because the automatic updater will not know how to handle all of that, so you will have to do it manually.
I doubt that any speed increase brought about by removing template variables is significant enough to justify such a major change.
I just changed some other strings and i've no error of any sort, including that of sessions..i'm still logged in Can you give me some of the incriminated strings?
Well..consider that the CPU load decreased by a 29%callumacrae wrote:It's a negligible performance gain, in my opinion.
- DavidIQ
- Customisations Team Leader
- Posts: 1904
- Joined: Thu Mar 02, 2006 4:29 pm
- Location: Earth
- Contact:
Re: Make phpBB faster/liter by replacing dynamic strings with static one
You completely ignored the part about multi-languages. If we were to go with what you're suggesting then there would have to be multiple versions of template files if there are different languages available on a board. I'm sure going through all template files to produce the desired language to display won't do your CPU usage any favors either.
The template engine in 3.1 has already been redone so I'm pretty sure you'll be seeing improvements there anyways.
The template engine in 3.1 has already been redone so I'm pretty sure you'll be seeing improvements there anyways.
Re: Make phpBB faster/liter by replacing dynamic strings with static one
It is fairly straightforward to perform this replacement on a single installation via regular expressions. Therefore I would like to see some benchmarks. Also, with and without APC for 4 total benchmarks.
Re: Make phpBB faster/liter by replacing dynamic strings with static one
I find it hard to believe that a few variable versus static replacements dropped cpu utilization by nearly a third.
Sometimes you're the windshield, sometimes you're the bug.