How to add a user to the ignore list?
[SMARTY] Should $this->compile_check logic check the timestamp of parent & included php files?
Hello Guest
  
  • Login
• Register…
• Start blog
  • Who, Where, When
• What can I do?
• What to Read?
  • Polls
• Avatars
• Interests
  • Cities and Countries
• Random blog
• Users search
  • Search
• Games
• Tests
• QAIX
  • Сообщества
• Talxy Chat
• Horoscope
• Online
 
Зарегистрируйся!

QAIX > PHP web-programming > [SMARTY] Should $this->compile_chec­k logic check the timestamp of parent & included php files? 29 May 2002 20:11:59

  Recent blog posts: 
  They have birthday today: 
  Forums:   
  Discuss: 
  Recent forum topics: 
  Recent forum comments:
  Moderators:

[SMARTY] Should $this->compile_chec­k logic check the timestamp of parent & included php files?

Robert V. Zwink 29 May 2002 20:11:59
 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_chec­k 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


Add comment
Ben Godfrey 29 May 2002 16:43:40 permanent link ]
 
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_chec­k 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


Add comment
Robert V. Zwink 29 May 2002 17:41:58 permanent link ]
 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/c­lasses/Smarty.class.­php");
include("$PHP_LIB/c­lasses/Another.class­.php");

$smarty = new Smarty;
if($smarty->is_cach­ed("template.html", $product_id)){
$smarty->display("t­emplate.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.ne­t/daid.php

-----Original Message-----
From: Ben Godfrey [mailto:ben@hypothetical.co.uk]
Sent: Wednesday, May 29, 2002 9:44 AM
To: smarty-general@list­s.php.net
Subject: Re: [SMARTY] Should $this->compile_chec­k 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_chec­k 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


--
Smarty General Mailing List (http://smarty.php.­net/)
To unsubscribe, visit: http://www.php.net/­unsub.php


Add comment
Peter Bowyer 29 May 2002 17:51:06 permanent link ]
 At 10:41 29/05/02 -0400, Robert V. Zwink wrote:>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.

But that's the correct behaviour. What's contained in your PHP files
should have no relevance to what's cached. If the Smarty class changes
then it shouldn't clear the templates as it has nothing much to do with the
HTML output.

Peter.

--oOo--
Narrow Gauge on the web - photos, directory and forums!
http://www.narrow-g­auge.co.uk
--oOo--
Glenbranter - Scottish narrow gauge in 009
http://glenbranter.­narrow-gauge.co.uk
--oOo--


--
Smarty General Mailing List (http://smarty.php.­net/)
To unsubscribe, visit: http://www.php.net/­unsub.php


Add comment
Andrei Zmievski 29 May 2002 18:13:00 permanent link ]
 On Wed, 29 May 2002, Robert V. Zwink wrote:> For the most part when I change a MySQL query within a PHP page it will have> an impact on the generated Smarty output. If I change the MySQL query> within an included php page it can also affect the Smarty output. We needed> to change a MySQL SELECT statement to only select LEFT(field, 255) for> performance reasons. This had an effect on records with fields longer than> 255.>
I might find a bug that when fixed could affect the generated output. The> problem now is that when the bug is fixed, the cache persists. It becomes> possible to have Smarty generated output of a php script persist even though> the script would no longer generate the same output. We don't neccesarily> want to purge all of the cached files when we update a page, we only want to> destory the cached output that could have been affected by the change.>
If we change a php page that generates output that is cached why would we> not want to update the cache when the php files are updated? The Smarty> class example is perfect, if I update the smarty class file, why wouldn't I> want to update all affected cache. They might end up being exactly the> same, but if there is a chance they would be different, it seems ideal to> have them updated immediately.

You can generate a different cache ID based on your PHP file. For
example, you could do md5() on the source of your PHP file and then use
that as part of the cache ID.

-Andrei http://www.graviton­ic.com/

"Are you implying that cryptic pointer arithmetic isn't just
as crystal clear as mere simple functions?
What kind of a C programmer are you?" -- Zeev Suraski

--
Smarty General Mailing List (http://smarty.php.­net/)
To unsubscribe, visit: http://www.php.net/­unsub.php


Add comment
Robert V. Zwink 29 May 2002 18:16:04 permanent link ]
 
What's contained in your PHP files> should have no relevance to what's cached.

For the most part when I change a MySQL query within a PHP page it will have
an impact on the generated Smarty output. If I change the MySQL query
within an included php page it can also affect the Smarty output. We needed
to change a MySQL SELECT statement to only select LEFT(field, 255) for
performance reasons. This had an effect on records with fields longer than
255.

I might find a bug that when fixed could affect the generated output. The
problem now is that when the bug is fixed, the cache persists. It becomes
possible to have Smarty generated output of a php script persist even though
the script would no longer generate the same output. We don't neccesarily
want to purge all of the cached files when we update a page, we only want to
destory the cached output that could have been affected by the change.

If we change a php page that generates output that is cached why would we
not want to update the cache when the php files are updated? The Smarty
class example is perfect, if I update the smarty class file, why wouldn't I
want to update all affected cache. They might end up being exactly the
same, but if there is a chance they would be different, it seems ideal to
have them updated immediately.

-Rob Z.





-----Original Message-----
From: Peter Bowyer [mailto:reywob@f2s.com]
Sent: Wednesday, May 29, 2002 10:51 AM
To: Robert V. Zwink; Ben Godfrey; smarty-general@list­s.php.net
Subject: RE: [SMARTY] Should $this->compile_chec­k logic check the
timestamp of parent & included php files?


At 10:41 29/05/02 -0400, Robert V. Zwink wrote:>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.

But that's the correct behaviour. What's contained in your PHP files
should have no relevance to what's cached. If the Smarty class changes
then it shouldn't clear the templates as it has nothing much to do with the
HTML output.

Peter.

--oOo--
Narrow Gauge on the web - photos, directory and forums!
http://www.narrow-g­auge.co.uk
--oOo--
Glenbranter - Scottish narrow gauge in 009
http://glenbranter.­narrow-gauge.co.uk
--oOo--


--
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


Add comment
Robert V. Zwink 29 May 2002 18:31:41 permanent link ]
 To do this within the php script I would need to read in the contents of
get_included_files(­), then md5_file() each element in the array. Then
concat the output for my cache id. I suppose I could also read in the
contents of get_included_files(­) then just get the modified timestamp using
filemtime(). Might make an interesting benchmark. Either one seems like
the correct method.

Thanks for your response. I sincerely appreciate the support this forum
offers. I will add the above method to each php file on the site when
generating the cache id, instead of making a change to the compile_check
logic.

Thanks!
Robert Zwink


-----Original Message-----
From: Andrei Zmievski [mailto:andrei@ispi.net]
Sent: Wednesday, May 29, 2002 11:13 AM
To: Robert V. Zwink
Cc: smarty-general@list­s.php.net
Subject: Re: [SMARTY] Should $this->compile_chec­k logic check the
timestamp of parent & included php files?


On Wed, 29 May 2002, Robert V. Zwink wrote:> For the most part when I change a MySQL query within a PHP page it will
have> an impact on the generated Smarty output. If I change the MySQL query> within an included php page it can also affect the Smarty output. We
needed> to change a MySQL SELECT statement to only select LEFT(field, 255) for> performance reasons. This had an effect on records with fields longer
than> 255.>
I might find a bug that when fixed could affect the generated output. The> problem now is that when the bug is fixed, the cache persists. It becomes> possible to have Smarty generated output of a php script persist even
though> the script would no longer generate the same output. We don't neccesarily> want to purge all of the cached files when we update a page, we only want
destory the cached output that could have been affected by the change.>
If we change a php page that generates output that is cached why would we> not want to update the cache when the php files are updated? The Smarty> class example is perfect, if I update the smarty class file, why wouldn't
want to update all affected cache. They might end up being exactly the> same, but if there is a chance they would be different, it seems ideal to> have them updated immediately.

You can generate a different cache ID based on your PHP file. For
example, you could do md5() on the source of your PHP file and then use
that as part of the cache ID.

-Andrei http://www.graviton­ic.com/

"Are you implying that cryptic pointer arithmetic isn't just
as crystal clear as mere simple functions?
What kind of a C programmer are you?" -- Zeev Suraski

--
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


Add comment
Peter Bowyer 29 May 2002 20:11:59 permanent link ]
 At 11:16 29/05/02 -0400, Robert V. Zwink wrote:>I might find a bug that when fixed could affect the generated output. The>problem now is that when the bug is fixed, the cache persists. It becomes>possible to have Smarty generated output of a php script persist even though>the script would no longer generate the same output. We don't neccesarily>want to purge all of the cached files when we update a page, we only want to>destory the cached output that could have been affected by the change.

Make a simple file containing the following code:
<?php
require_once 'Smarty/Smarty.php'­;
$smarty = new Smarty;
$smarty->clear_comp­iled_tpl();
$smarty->clear_all_­cache();
?>

Then, every time you make a change just run this to remove the compiled
templates + cache. Of course you don't need to remove the compiled
templates if compile_check = On, but as I don't know your setup then I've
included it.

HTH
Peter

--
Maple Design - quality web design and programming
http://www.mapledes­ign.co.uk


--
Smarty General Mailing List (http://smarty.php.­net/)
To unsubscribe, visit: http://www.php.net/­unsub.php


Add comment
 

Add new comment

As:
Login:  Password:  
 
 
  
 
Пожалуйста, относитесь к собеседникам уважительно, не используйте нецензурные слова, не злоупотребляйте заглавными буквами, не публикуйте рекламу и объявления о купле/продаже, а также материалы нарушающие сетевой этикет или УК РФ.


QAIX > PHP web-programming > [SMARTY] Should $this->compile_chec­k logic check the timestamp of parent & included php files? 29 May 2002 20:11:59

see also:
[PHP-DEV] Re: [PHP-CVS] cvs: php-src…
[PHP-DEV] cvs.php.net
[PHP-DEV] execution timeout causes…
пройди тесты:
see also:
Learning PHP
TuneClone Audio Converter 1.03 Released…
How to strip DRM off iTunes M4P music…

  Copyright © 2001—2008 QAIX
Idea: Miсhael Monashev
Помощь и задать вопросы можно в сообществе support.qaix.com.
Сообщения об ошибках оставляем в сообществе bugs.qaix.com.
Предложения и комментарии пишем в сообществе suggest.qaix.com.
Информация для родителей.
Write us at:
If you would like to report an abuse of our service, such as a spam message, please .