Re: What can prematurely expire a cache?

From: Date: Thu, 03 Jan 2002 22:41:30 +0000
Subject: Re: What can prematurely expire a cache?
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-2490@lists.php.net to get a copy of this message
Okay thank you for your help (and all those that helped out). I think I have finally squashed this bug... Okay, my 'viewcomments.php' was including 'news.php' which in turned called 'news.tpl' to display the news post at the top of each comment... but the reference to $tpl->fetch('news.tpl') wasn't passing a cache_id. WHY this affects index.php and the cache of 'index.tpl' is completely beyond me, but adding that fixed the caching problems. I can see how that would result it in expiring all my 'viewcomments.tpl' caches (because viewcomments.tpl includes news.tpl and if news.tpl changes, it regenerates the cache), but I'm still failing to see the relationship to 'index.php' and 'index.tpl.' Oh well, at least it seems to be working now. Look guys I really appreciate all the help and the work on Smarty. Although the past couple of weeks have been frustrating, you guys have all been a great help. Thanks! Hopefully soon my project will be completed and the PHP community will have a useful fully template-ized system web site management system. I just have to finish coding a few various modules and a bit of the admin left. Thanks again. Brian ----- Original Message ----- From: Monte Ohrt <monte@ispi.net> To: smarty@lists.ispi.net Date: 1/3/02 6:36:33 AM > >* caching disabled >* $force_compile = true >* $compile_check = true and involved template was modified >* cache lifetime expires >* programatically removing cache files >* manually removing files from cache_dir > >Thats what I can think of off the top of my head. > >"Brian E. Lozier" wrote: >> >> I'm still struggling with the caching problem mentioned in the last few emails. So my >> question now is, what >> exactly can expire a cache? Why would a cache of index.tpl be expired after accessing an >> unrelated page >> that doesn't even reference index.tpl? I tested sample code and it SEEMS to work >> correctly in my test... but >> the code is virtually identical (only difference is that the big script gets data from a >> database and the >> other doesn't). Here is the code that doesn't work: >> http://www.massassi.org/saberworks/source.phps and >> here's the test code that works: >> >> // Classes >> include_once('classes/template.php'); >> >> // Start the template >> $tpl = new Template; >> $tpl->caching = true; >> >> // Assign Title (in testmain.tpl) >> $tpl->assign('Title', 'A simple cache test.'); >> >> // Put some dynamic content in testmain.tpl >> if($tpl->is_cached('testcache3.tpl', $cache_id)) { >> echo '<p>This is cached.</p>'; >> $tpl->assign('Cached', 'Yes'); >> } >> else { >> echo '<p>This is not cached.</p>'; >> $tpl->assign('Cached', 'No'); >> } >> >> // Assign the content... this should fetch the cached copy >> // by default if it's not expired >> $tpl->assign('Content', $tpl->fetch('testcache3.tpl', >> $cache_id)); >> >> // Set caching to false for the display of testmain.tpl >> // This is so the dynamic content of testmain.tpl isn't cached! >> $tpl->caching = false; >> $tpl->display('testmain.tpl'); >> >> Brian >> ------------------------------------ >> "How should I know if it works? That's what beta testers are for. I only coded >> it." - Linus Torvalds >> >> --- >> You are currently subscribed to smarty as: monte@ispi.net >> To unsubscribe send a blank email to $subst('Email.Unsub') >> Visit Smarty's homepage at ‹‡Ã >> Çm�Kƒy˜âd™Hhttp://www.phpinsider.com/php/code/Smarty/ > >-- >Monte Ohrt <monte@ispi.net> >http://www.ispi.net/ > >--- >You are currently subscribed to smarty as: brian@massassi.net >To unsubscribe send a blank email to $subst('Email.Unsub') >Visit Smarty's homepage at >http://www.phpinsider.com/php/code/Smarty/

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