Re:Re:Re:[BEGINNER] Question about caching

From: Date: Fri, 28 Dec 2001 22:42:50 +0000
Subject: Re:Re:Re:[BEGINNER] Question about caching
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-2424@lists.php.net to get a copy of this message
>I see. Your best bet then would be to use the fetched contents of inner >template as the $cache id. Alternatively, you can use $RESOURCE URI or >some other cache id on fetch() call and don't use it on display() since >the main template is so simple. But that's the problem! If I use it on the inner fetch() calls, then do a standard $tpl->display('main.tpl') it returns the same cached file NO MATTER WHAT PAGE I'M ON. Whatever page is called *FIRST* after turning on caching, that's the one that gets cached, no matter what I pass in $tpl->fetch() as the cache_id. It just ignores that. How do cache IDs work? Is there a specific cache_id for each template? Like, if I have: main.tpl => cache_id: 5 main.tpl => cache_id: 6 main.tpl => cache_id: 7 Then can I have also: index.tpl => cache_id: 5 index.tpl => cache_id: 6 index.tpl => cache_id: 7 And those are all completely separate cache files? Or is the cache_id unique per the directory, meaning, you will never get repeats no matter what template you're compiling? The only way I've even got it remotely to work correctly is if I pass $REQUEST_URI to *both* the ->fetch and the display, although they're both on completely separate templates (main.tpl and index.tpl). But then, looking at the cache, it actually caches it TWICE, once with the main.tpl wrapped around it, and one without. But that still doesn't solve the problem and I think it's actually making things slower because it has to write/test/read 2 separate cache files instead of just one. Using the fetched contents of the inner template.. how does cache_id work? Because that's a *lot* of data at times! I don't know whether you guys are dodging my questions or I'm just not being clear. Is there a way to insert cached data to a non-cached template? For instance: $tpl = new Smarty; if(!$tpl->is_cached('index.tpl', $REQUEST_URI)) { // do my db calls $dbInfo = mysql_db_junk(); // assign it $tpl->assign('dbInfo', $dbInfo); // fetch the right template to include it $tpl->assign('Content', $tpl->fetch('index.tpl', $REQUEST_URI)); } $tpl->display('main.tpl'); In the above example, I *only* want the content of 'index.tpl' cached, nothing else. Is this possible? ----- Original Message ----- From: Andrei Zmievski <andrei@ispi.net> To: "Brian E. Lozier" <brian@massassi.net> Date: 12/28/01 2:17:46 PM > >On Fri, 28 Dec 2001, Brian E. Lozier wrote: >> The main template doesn't include another template. The main template has a >> {$Content} field that my >> application populates depending on what page you're accessing. >> >> *ALL* my $tpl->display() calls (on every single one of my pages) look like: >> >> $tpl->display('main.tpl'); >> >> >> At the end of EVERY page in my application.  Because 'main.tpl' contains my entire design. >> >> [html][body] >> {$Content} >> [/body][/html] >> >> Then I populate {Content} with a $tpl->fetch() command, such as: >> >> $tpl->assign('Content', $tpl->fetch('userregister.tpl')); >> or on a different page: >> $tpl->assign('Content', $tpl->fetch('viewcomments.tpl')); >> >> ----- Original Message ----- >> From: Andrei Zmievski <andrei@ispi.net> >> To: "Brian E. Lozier" <brian@massassi.net> >> Date: 12/28/01 1:06:29 PM > >I see. Your best bet then would be to use the fetched contents of inner >template as the $cache id. Alternatively, you can use $RESOURCE URI or >some other cache id on fetch() call and don't use it on display() since >the main template is so simple. > >-Andrei >* Proximity bug: when the program crashes in front of important visitors. *

« previous php.smarty.general (#2424) next »