Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

included files not getting cached with newest cvs?

 
Post new topic   Reply to topic    Smarty Forum Index -> Bugs
View previous topic :: View next topic  
Author Message
kdo
Smarty n00b


Joined: 21 Aug 2003
Posts: 3

PostPosted: Thu Aug 21, 2003 10:49 pm    Post subject: included files not getting cached with newest cvs? Reply with quote

hi,
it seems like included files are not getting cached with the newest cvs version. I've tried to trace the bug back and found out that the only line where files are getting written to the cache is in Smarty::fetch() on line 1347 and it doesn't seem to be called when a file is included.

the only way to get around this was to write a compile-function for "include_cached" which emulates a display() call instead of _smarty_include() but that's really just an ugly hack I think.

did i miss something or is it a real bug?
btw. cvs update gives me "No space left on device" Shocked
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Thu Aug 21, 2003 11:40 pm    Post subject: Reply with quote

i cannot reproduce this as a bug. what do you mean by "not being cached" in particular?

there is no cache-file generated per included template, just one cache-file per display()-call. you'll find the contents of your cached include inside the cache-file of the including one.

BTBW: the cvs-service seems back up again.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kdo
Smarty n00b


Joined: 21 Aug 2003
Posts: 3

PostPosted: Fri Aug 22, 2003 12:57 am    Post subject: Reply with quote

aahhh i see what you mean, because i was calling is_cached() on the include file and not the file which was cached (the the one including the other) i always got "false" with is_cached('included_file.html'). so it was clearly my fault.
but maybe it would be handy to cache these files as well as they could be reused somewhere else.
for example:
{include file="header.html"}
contentblabla
{include file="footer.html"}

every other file including header.html and footer.html would have to regenerate and recache their contents. this makes reusability of included components in cached environments more complicated as they need to be included at script and not at template level by:
$smarty->display('header.html');
$smarty->display('content.html');
$smarty->display('footer.html');
which of course caches each file individually
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Fri Aug 22, 2003 1:12 am    Post subject: Reply with quote

kdo wrote:
every other file including header.html and footer.html would have to regenerate and recache their contents. this makes reusability of included components in cached environments more complicated as they need to be included at script and not at template level by:
$smarty->display('header.html');
$smarty->display('content.html');
$smarty->display('footer.html');
which of course caches each file individually


Hi kdo.

Your suggestion reminds me of the inline discussion that occurs every so often in regards to compiled templates. Still, I think that when applied to caches, the story is a bit different. In my mind, there is little (if any) benefit to caching the sub-templates if they themselves are not directly called by display.

Here's why I think that is so:

Say you want to cache your main template. Once the cache file is generated, there is no need for subsequent calls to the template to do anything but retrieve the cache file -- all of the sub-templates are already processed before the cache operation and are thus relevant to that template (and cache_id/compile_id request). This is what Messju already pointed out.

Okay, now you have another master template that also uses the same sub-templates, as-per your example. There is no reason to believe that the already cached contents of the sub-templates (assuming your suggestion) are relevant to the new master template. For example, they may not even relate to the same cache_id or compile_id (which is not controllable via includes). On the other hand, the (already) compiled sub-templates are exactly what are required and any additional substitutions that may be needed by the new master template are still possible (if any at all).

In many cases, things like headers and footers don't change from page to page (or for multiple master templates) meaning that the first compilation of those items will likely result in compile files that are nearly identical to their cache images.

I think that the key is that cached files are generated from compiled files and compiled files already have the majority of processing completed--at least for mostly static templates like headers/footer, etc.

Cheers


Last edited by boots on Fri Aug 22, 2003 4:54 am; edited 1 time in total
Back to top
View user's profile Send private message
kdo
Smarty n00b


Joined: 21 Aug 2003
Posts: 3

PostPosted: Fri Aug 22, 2003 1:31 am    Post subject: Reply with quote

now I got the point! I simply oversaw the fact, that cached content is really static and does not care about the way it was generated (which of course is the real reason for caching stuff Rolling Eyes ). maybe I should not post bugs late at night Wink

thx & please keep up the great work
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Bugs All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP