RE: [SMARTY] Should $this->compile_check logic check the timestamp of parent & included php files?

From: Date: Wed, 29 May 2002 14:41:58 +0000
Subject: RE: [SMARTY] Should $this->compile_check logic check the timestamp of parent & included php files?
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-4427@lists.php.net to get a copy of this message
Thanks for your reply. Our include files don't output HTML, they contain information about our database queries, along with connection information. For example if I change the database I connect to within an include file, the smarty cache will persist until I manually remove it. We are not using the smarty {include}, but instead php's include(). <?php include("$PHP_LIB/classes/Smarty.class.php"); include("$PHP_LIB/classes/Another.class.php"); $smarty = new Smarty; if($smarty->is_cached("template.html", $product_id)){ $smarty->display("template.html", $product_id); } ?> Right now if the template "template.html" is updated, the is_cached() method will return false, and the cache will be destroyed. But if "Smarty.class.php", "Another.class.php", or "template.php" is updated the is_cached() method will still return true because Smarty currently does not test the timestamp of the parent or included php files to determine if the cache should be expired. My solution to this is to modify the is_cached method to take into account the parent script and all supporting include files timestamp. This is the functionality I want to add, I wonder what the disadvantages might be. This may have been talked about previously and I wonder why is_cached only tests the template timestamp and not the parent php documents. Thanks for any help. Robert Zwink http://www.zwink.net/daid.php -----Original Message----- From: Ben Godfrey [mailto:ben@hypothetical.co.uk] Sent: Wednesday, May 29, 2002 9:44 AM To: smarty-general@lists.php.net Subject: Re: [SMARTY] Should $this->compile_check logic check the timestamp of parent & included php files? Rob, Instead of adding functionality you could create a plugin for use with {insert} to include files. The output of an insert is not cached. This would be a slower solution, since you loose the caching on anything coming from those included scripts, but you could just use this technique until your includes are in a more stable state and then go back to using include. It's one way anyway. Ben Godfrey On Tuesday, May 28, 2002, at 07:42 PM, Robert V. Zwink wrote: > I am considering adding functionality to our implementation of > Smarty, and I > wanted to know what the disadvantages might be. > > The functionality I want to add is that when the parent php > file, or the php > files included with include() or require_once(), have been > updated, Smarty > would automatically expire the related cache files. My > reasoning is that > when one of our developers updates a php page, or a file that > is typically > included, the Smarty cache persists because the HTML template > has not been > updated. > > We don't necessarily want to delete _all_ of the cache when we > send a change > to our development servers. If I add functionality to check > the timestamp > of parent php files (and included files), the affected cached will > automatically be regenerated. > > I'm considering using the php function get_included_files() during the > $this->compile_check logic to get the last modified timestamp > of all php > (and included files) when testing whether not to expire the cache. > > Has this been addressed in the past? Is there a reason why the > logic only > checks the timestamp of the included templates and not the > actual php pages? > Do most people just purge the entire cache when php on the site > is updated? > > Just curious, thanks for your time and a wonderful product. > > -Rob Z. > > > -- > Smarty General Mailing List (http://smarty.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Smarty General Mailing List (http://smarty.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

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