Author |
Message |
Dog Cow Board Member
Joined: 18 Nov 2008
Posts: 378
|
Posted: Sun Feb 01, 2009 3:18 pm Post subject: Merging Templace Cache files |
|
|
Hi,
I had an idea the other day about merging template cache files and whether or not that could result in a "speed gain" or any other benefits.
The typical page requires 3 template files to render fully, and some pages may require more. I'm using the Speedy templates system by brainy, which just like every other template caching mechanism, puts each .tpl file into its own cache.
My question: If instead of storing the 3 .tpl files needed to generate the index into 3 separate cache files, we put those all into one cache file, would that give any benefits? _________________ Moof!
Lincoln's Tomb, Oak Ridge Cemetery, Springfield IL • Mac 512K Blog • Mac GUI |
|
Back to top |
|
|
Ptirhiik Board Member
Joined: 19 Nov 2008
Posts: 114
|
Posted: Mon Feb 02, 2009 3:46 am Post subject: Re: Merging Templace Cache files |
|
|
None noticeable. And you need the three, as the header, body & footer of the page are not processed at the same time. |
|
Back to top |
|
|
Dog Cow Board Member
Joined: 18 Nov 2008
Posts: 378
|
Posted: Mon Feb 02, 2009 2:00 pm Post subject: Re: Merging Templace Cache files |
|
|
Yes, I made mental changes for what would be needed. Template as it is just keeps adding on as new .tpl files are declared and variables parsed.
Basically, you'd have to modify template.php to keep storing the .tpl files and variables in memory, and make sure nothing is parsed. Then when you got to the final pparse() statement in page_tail, you would then have the template parse everything in one big file and save as cache.
For retrieving cache file, template would find the .php file that matches filename->body and use that. _________________ Moof!
Lincoln's Tomb, Oak Ridge Cemetery, Springfield IL • Mac 512K Blog • Mac GUI |
|
Back to top |
|
|
drathbun Board Member
Joined: 24 Jul 2008
Posts: 729 Location: Texas
|
Posted: Fri Feb 06, 2009 5:25 pm Post subject: Re: Merging Templace Cache files |
|
|
Dog Cow, which version of speedy are you using right now? I went through so many, and I know some of them had bugs that impacted by board. I'm curious as to which one you've settled on using. _________________ phpBBDoctor Blog |
|
Back to top |
|
|
Dog Cow Board Member
Joined: 18 Nov 2008
Posts: 378
|
|
Back to top |
|
|
drathbun Board Member
Joined: 24 Jul 2008
Posts: 729 Location: Texas
|
Posted: Mon Feb 09, 2009 1:26 pm Post subject: Re: Merging Templace Cache files |
|
|
ok, thanks, I will have to see if I have that version still. If not, I assume I can pester you for a copy. _________________ phpBBDoctor Blog |
|
Back to top |
|
|
Dog Cow Board Member
Joined: 18 Nov 2008
Posts: 378
|
Posted: Mon Feb 09, 2009 3:58 pm Post subject: Re: Merging Templace Cache files |
|
|
drathbun wrote: | ok, thanks, I will have to see if I have that version still. If not, I assume I can pester you for a copy. |
I have every single version he ever released. Pack rat. _________________ Moof!
Lincoln's Tomb, Oak Ridge Cemetery, Springfield IL • Mac 512K Blog • Mac GUI |
|
Back to top |
|
|
drathbun Board Member
Joined: 24 Jul 2008
Posts: 729 Location: Texas
|
Posted: Mon Feb 09, 2009 4:08 pm Post subject: Re: Merging Templace Cache files |
|
|
I had up through 0.1.5 and then stopped for some reason. I was able to find 0.1.6 via google's cache. I'm testing it now...
Which part of the code did you comment out for the space removal? _________________ phpBBDoctor Blog |
|
Back to top |
|
|
Dog Cow Board Member
Joined: 18 Nov 2008
Posts: 378
|
Posted: Mon Feb 09, 2009 5:17 pm Post subject: Re: Merging Templace Cache files |
|
|
drathbun wrote: |
Which part of the code did you comment out for the space removal? |
Let me think.... it was basically the last two lines of functions_compile.php, IIRC.
Ok, here it is:
Code: |
// Combine php tags
$code = preg_replace('/\s*\?>\s*<\?php\*/', '', $code);
//$code = preg_replace('/\s*\n\s*/', '', $code);
//$code = preg_replace('/\s+/', ' ', $code);
|
The reason I did that was because it was messing up Javascript. Some day I may devote more time to sorting out the problem. Until then, no.
I made some other little changes to the code as well, but I don't remember if they are significant or not. I removed language caching, though. Since my list is a lot longer than the default one and I don't have time to spend researching it all! _________________ Moof!
Lincoln's Tomb, Oak Ridge Cemetery, Springfield IL • Mac 512K Blog • Mac GUI |
|
Back to top |
|
|
drathbun Board Member
Joined: 24 Jul 2008
Posts: 729 Location: Texas
|
Posted: Mon Feb 09, 2009 5:34 pm Post subject: Re: Merging Templace Cache files |
|
|
I took those two lines out, but the code still messed up on this site. It didn't render some of the topics with attachments correctly. I'll go back to it when I have time. _________________ phpBBDoctor Blog |
|
Back to top |
|
|
Dog Cow Board Member
Joined: 18 Nov 2008
Posts: 378
|
Posted: Mon Feb 09, 2009 7:14 pm Post subject: Re: Merging Templace Cache files |
|
|
drathbun wrote: | It didn't render some of the topics with attachments correctly. I'll go back to it when I have time. |
I remember reading the topic and you kept having problems with the attachment mod. I last used the attach mod back in 2006, so I've never had it with Brainy's speedy templates.
YMMV, I suppose. _________________ Moof!
Lincoln's Tomb, Oak Ridge Cemetery, Springfield IL • Mac 512K Blog • Mac GUI |
|
Back to top |
|
|
Ptirhiik Board Member
Joined: 19 Nov 2008
Posts: 114
|
Posted: Tue Feb 10, 2009 3:07 am Post subject: Re: Merging Templace Cache files |
|
|
To remove front space/tabs - what will not break the js and will save a considerable amount of chars - you can use this:
Code: | $lf = '
';
$code = preg_replace('#([\n\r]+)[\s\t]*#', $lf, $code); |
nb: this apply to the .tpl content, not to the generated php.
To remove extra ?><?php from the generated php, you can use this:
Code: | $res = preg_replace('#[\n\r\s\t]+\?\>[\n\r\s\t]*\<\?php[\n\r\s\t]+#is', $lf, $res); |
As far as I remember, the attachment mod - so the cash mod - is playing with the tpl object properties (eg vars) to display the attachments, so you will probably have to rewrite that part to go back to the phpBB logic. |
|
Back to top |
|
|
Dog Cow Board Member
Joined: 18 Nov 2008
Posts: 378
|
Posted: Tue Feb 10, 2009 3:43 pm Post subject: Re: Merging Templace Cache files |
|
|
Thank you for the improvements, Ptirhiik.
As an aside, it is notable to mention that Google's home page has the HTML compressed, as do the results pages, both of which contain Javascript code. _________________ Moof!
Lincoln's Tomb, Oak Ridge Cemetery, Springfield IL • Mac 512K Blog • Mac GUI |
|
Back to top |
|
|
|