phpBB2Refugees.com Logo
Not affiliated with or endorsed by the phpBB Group

Register •  Login 

Continue the legacy...

Welcome to all phpBB2 Refugees!Wave Smilie

This site is intended to continue support for the legacy 2.x line of the phpBB2 bulletin board package. If you are a fan of phpBB2, please, by all means register, post, and help us out by offering your suggestions. We are primarily a community and support network. Our secondary goal is to provide a phpBB2 MOD Author and Styles area.

Merging Templace Cache files


 
Search this topic... | Search phpBB2 Discussion... | Search Box
Register or Login to Post    Index » phpBB2 Discussion  Previous TopicPrint TopicNext Topic
Author Message
Dog Cow
Board Member



Joined: 18 Nov 2008

Posts: 378


flag
PostPosted: 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 ILMac 512K BlogMac GUI
Back to top
Ptirhiik
Board Member



Joined: 19 Nov 2008

Posts: 114


flag
PostPosted: 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


flag
PostPosted: 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 ILMac 512K BlogMac GUI
Back to top
drathbun
Board Member



Joined: 24 Jul 2008

Posts: 729
Location: Texas


flag
PostPosted: 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


flag
PostPosted: Sun Feb 08, 2009 2:29 pm 
Post subject: Re: Merging Templace Cache files

I use the latest version 0.1.6 and I commented-out the code for removing all blanks and newlines.

Have not had a single problem with it in over 3 months.

_________________
Moof!
Lincoln's Tomb, Oak Ridge Cemetery, Springfield ILMac 512K BlogMac GUI
Back to top
drathbun
Board Member



Joined: 24 Jul 2008

Posts: 729
Location: Texas


flag
PostPosted: 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. icon_wink.gif
_________________
phpBBDoctor Blog
Back to top
Dog Cow
Board Member



Joined: 18 Nov 2008

Posts: 378


flag
PostPosted: 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. icon_wink.gif

I have every single version he ever released. Pack rat. icon_mrgreen.gif

_________________
Moof!
Lincoln's Tomb, Oak Ridge Cemetery, Springfield ILMac 512K BlogMac GUI
Back to top
drathbun
Board Member



Joined: 24 Jul 2008

Posts: 729
Location: Texas


flag
PostPosted: 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


flag
PostPosted: 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 ILMac 512K BlogMac GUI
Back to top
drathbun
Board Member



Joined: 24 Jul 2008

Posts: 729
Location: Texas


flag
PostPosted: 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


flag
PostPosted: 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. icon_neutral.gif

_________________
Moof!
Lincoln's Tomb, Oak Ridge Cemetery, Springfield ILMac 512K BlogMac GUI
Back to top
Ptirhiik
Board Member



Joined: 19 Nov 2008

Posts: 114


flag
PostPosted: 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


flag
PostPosted: 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 ILMac 512K BlogMac GUI
Back to top
Display posts from previous:   
Register or Login to Post    Index » phpBB2 Discussion  Previous TopicPrint TopicNext Topic
Page 1 of 1 All times are GMT - 4 Hours
 
Jump to:  

Index • About • FAQ • Rules • Privacy • Search •  Register •  Login 
Not affiliated with or endorsed by the phpBB Group
Powered by phpBB2 © phpBB Group
Generated in 0.0659 seconds using 17 queries. (SQL 0.0088 Parse 0.0010 Other 0.0561)
phpBB Customizations by the phpBBDoctor.com
Template Design by DeLFlo and MomentsOfLight.com Moments of Light Logo