<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Invalidate Smarty Cache Using Cache Dependency Files</title>
	<atom:link href="http://www.slepi.net/blog/programming/invalidate-smarty-cache-using-cache-dependency-files.html/feed" rel="self" type="application/rss+xml" />
	<link>http://www.slepi.net/blog/programming/invalidate-smarty-cache-using-cache-dependency-files.html</link>
	<description>A Web Designer and Application Developer</description>
	<lastBuildDate>Sat, 07 Jan 2012 10:32:27 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
	<item>
		<title>By: Wiras Adi</title>
		<link>http://www.slepi.net/blog/programming/invalidate-smarty-cache-using-cache-dependency-files.html#comment-17</link>
		<dc:creator>Wiras Adi</dc:creator>
		<pubDate>Sun, 15 Nov 2009 13:58:34 +0000</pubDate>
		<guid isPermaLink="false">http://localhost:8080/php/SlepiEvolved/?p=41#comment-17</guid>
		<description>Hello Andrew,

Yes, that&#039;s how it works, you need to update the modification time of the dependency files every time you make changes to the underlying data (in PHP you can use the built-in touch() function).

About your question &quot;how to make Smarty knows which cached files in the pool needs to be refreshed when particular underlying data changed?&quot;, the first thing crosses my mind is to implement a kind of naming conventions technique in how you make the dependency files. Say, you have a certain template that dependent to rows of data who have, say, &quot;Japan&quot; as the value of its country column. Then you might want to name the dependency files for that template something like &quot;dep_file_japan.dep&quot;, another_dep_file_japan.dep&quot;, etc. Using a simple Regex checking, you could easily touch() all the dependency files related to that specific data and template.

As an alternative you can also use a kind of configuration settings (using database or just configuration files) in order to &quot;map&quot; template files to its underlying data. But this could unnecessarily complicate things as your data grows.

I hope I&#039;ve made myself clear with that explanation there. If you have a better solution I&#039;d be glad if you like to share it here.</description>
		<content:encoded><![CDATA[<p>Hello Andrew,</p>
<p>Yes, that&#8217;s how it works, you need to update the modification time of the dependency files every time you make changes to the underlying data (in PHP you can use the built-in touch() function).</p>
<p>About your question &#8220;how to make Smarty knows which cached files in the pool needs to be refreshed when particular underlying data changed?&#8221;, the first thing crosses my mind is to implement a kind of naming conventions technique in how you make the dependency files. Say, you have a certain template that dependent to rows of data who have, say, &#8220;Japan&#8221; as the value of its country column. Then you might want to name the dependency files for that template something like &#8220;dep_file_japan.dep&#8221;, another_dep_file_japan.dep&#8221;, etc. Using a simple Regex checking, you could easily touch() all the dependency files related to that specific data and template.</p>
<p>As an alternative you can also use a kind of configuration settings (using database or just configuration files) in order to &#8220;map&#8221; template files to its underlying data. But this could unnecessarily complicate things as your data grows.</p>
<p>I hope I&#8217;ve made myself clear with that explanation there. If you have a better solution I&#8217;d be glad if you like to share it here.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Toan</title>
		<link>http://www.slepi.net/blog/programming/invalidate-smarty-cache-using-cache-dependency-files.html#comment-16</link>
		<dc:creator>Andrew Toan</dc:creator>
		<pubDate>Sun, 15 Nov 2009 05:43:31 +0000</pubDate>
		<guid isPermaLink="false">http://localhost:8080/php/SlepiEvolved/?p=41#comment-16</guid>
		<description>Hello, Wiras
Thanks for your post. 
I&#039;m really like your file-based cache dependency based on Smarty. But i have some questions i still don&#039;t understant. Can u make it clearer for me?

In the even, i update the data in my database and my system has a lot of template file (*.tpl). How can i make the Smarty know which template or which cache need to regenerate again. I just has an idea: each template file i also have a file-based dependency and whenever i update the specific data, i also update the modification time of dependent file. 

Hope u reply soon</description>
		<content:encoded><![CDATA[<p>Hello, Wiras<br />
Thanks for your post.<br />
I&#8217;m really like your file-based cache dependency based on Smarty. But i have some questions i still don&#8217;t understant. Can u make it clearer for me?</p>
<p>In the even, i update the data in my database and my system has a lot of template file (*.tpl). How can i make the Smarty know which template or which cache need to regenerate again. I just has an idea: each template file i also have a file-based dependency and whenever i update the specific data, i also update the modification time of dependent file. </p>
<p>Hope u reply soon</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Wiras Adi</title>
		<link>http://www.slepi.net/blog/programming/invalidate-smarty-cache-using-cache-dependency-files.html#comment-13</link>
		<dc:creator>Wiras Adi</dc:creator>
		<pubDate>Thu, 01 May 2008 13:24:44 +0000</pubDate>
		<guid isPermaLink="false">http://localhost:8080/php/SlepiEvolved/?p=41#comment-13</guid>
		<description>Hello Antonio,

Actually, the technique I wrote in this post is merely intended to be a mechanism to refresh the cache at precisely when the page need to be refreshed. With cache_lifetime Smarty currently provides, cached page will refresh only when it reaches its lifetime in the pool. Thus there’s a possibility that the page doesn’t display a very actual data when some data changes happened within the lifetime of the cache. The technique tries to make the cache dependent to external events to trigger the refreshing.

On the other hand, multiple caching is a way to display different versions of a page conditionally, where one page has multiple displays depending on some parameters. With multiple caching, Smarty can cache all possible displays. But it still lack a kind of “real-time” cache expiration support. And this file-based cache dependency technique can also be applied in conjunction multiple caching, in a similar way as in ordinary caching mechanism.

About your idea to “inject” the file names and timestamps information in cache_id, don’t you think that it would require relatively much works tweaking the Smarty system instead of just extend the class?

I haven’t tried it yet, but I really think that it’s a nice idea as it might lead to a cleaner application design than the one I proposed here.</description>
		<content:encoded><![CDATA[<p>Hello Antonio,</p>
<p>Actually, the technique I wrote in this post is merely intended to be a mechanism to refresh the cache at precisely when the page need to be refreshed. With cache_lifetime Smarty currently provides, cached page will refresh only when it reaches its lifetime in the pool. Thus there’s a possibility that the page doesn’t display a very actual data when some data changes happened within the lifetime of the cache. The technique tries to make the cache dependent to external events to trigger the refreshing.</p>
<p>On the other hand, multiple caching is a way to display different versions of a page conditionally, where one page has multiple displays depending on some parameters. With multiple caching, Smarty can cache all possible displays. But it still lack a kind of “real-time” cache expiration support. And this file-based cache dependency technique can also be applied in conjunction multiple caching, in a similar way as in ordinary caching mechanism.</p>
<p>About your idea to “inject” the file names and timestamps information in cache_id, don’t you think that it would require relatively much works tweaking the Smarty system instead of just extend the class?</p>
<p>I haven’t tried it yet, but I really think that it’s a nice idea as it might lead to a cleaner application design than the one I proposed here.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Antonio Bueno</title>
		<link>http://www.slepi.net/blog/programming/invalidate-smarty-cache-using-cache-dependency-files.html#comment-12</link>
		<dc:creator>Antonio Bueno</dc:creator>
		<pubDate>Tue, 29 Apr 2008 06:40:58 +0000</pubDate>
		<guid isPermaLink="false">http://localhost:8080/php/SlepiEvolved/?p=41#comment-12</guid>
		<description>I’m considering Smarty for my site and found your post when looking for information on Smarty caching. I like your file-based idea although I find it a bit restrictive (I miss including URL parameters, for example).

But wouldn’t this be a particular case of “multiple caches”?
http://www.smarty.net/manual/en/caching.multiple.caches.php

To replicate your solution I would combine file names and timestamps in a single “cache_id” (maybe a hash).</description>
		<content:encoded><![CDATA[<p>I’m considering Smarty for my site and found your post when looking for information on Smarty caching. I like your file-based idea although I find it a bit restrictive (I miss including URL parameters, for example).</p>
<p>But wouldn’t this be a particular case of “multiple caches”?<br />
<a href="http://www.smarty.net/manual/en/caching.multiple.caches.php" rel="nofollow">http://www.smarty.net/manual/en/caching.multiple.caches.php</a></p>
<p>To replicate your solution I would combine file names and timestamps in a single “cache_id” (maybe a hash).</p>
]]></content:encoded>
	</item>
</channel>
</rss>

