Re: What can prematurely expire a cache?

From: Date: Thu, 03 Jan 2002 00:57:52 +0000
Subject: Re: What can prematurely expire a cache?
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-2479@lists.php.net to get a copy of this message
Correction: http://www.massassi.org/saberworks/source.php is the page that doesn't work. ----- Original Message ----- From: Brian E. Lozier <brian@massassi.net> To: smarty@lists.ispi.net Date: 1/2/02 4:52:05 PM > >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: 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 (#2479) next »