Question about caching

From: Date: Sat, 20 Sep 2003 16:43:49 +0000
Subject: Question about caching
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-10247@lists.php.net to get a copy of this message
Hello all, I have a quick question about caching. At this moment, I have the following template files to display a news section on my site: news.tpl: runs trough an array of newsitems, assigned by my php files newsitem.tpl: included by news.tpl for every newsitem (every row) in the array; shows the content of one newsitem This is pretty straight-forward, I hope you understand what I mean. Now I had a thought about caching the separate newsitem.tpl files, since most of the times, once a newsitem is written, it doesn't change anymore. Is this possible? How do I do this? I think in this situation, the template designer has to decide if he wants to cache a newsitem.tpl, and not the creator of the php-files, since the newsitems.tpl files are included by news.tpl, and not by a php-file? So now I have to write php code (stuff like if ($smarty->is_cached('newsitem.tpl', 'some unique key'), ...) in my template files? So basically, I would cache the newsitem.tpl files based on their id, which includes their id in the databases, something like 'NEWSITEM-43'. Do you think this is a good way of caching? Or should I cache the whole news.tpl file instead, so I can also check if I need to query my database anyway, because with this method of caching (caching newsitem.tpl instead of news.tpl), you can't check if you need to query your database yes or no? Thanks for your given input, Peter

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