<?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: Cache duration and configuration tips</title>
	<atom:link href="http://www.cake-toppings.com/2009/03/19/cache-duration-and-configuration-tips/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cake-toppings.com/2009/03/19/cache-duration-and-configuration-tips/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=cache-duration-and-configuration-tips</link>
	<description>Tips &#38; tricks about (Cake)PHP, javascript, AJAX, etc.</description>
	<lastBuildDate>Fri, 11 Nov 2011 16:16:11 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
	<item>
		<title>By: morris</title>
		<link>http://www.cake-toppings.com/2009/03/19/cache-duration-and-configuration-tips/comment-page-1/#comment-1110</link>
		<dc:creator>morris</dc:creator>
		<pubDate>Fri, 03 Apr 2009 20:40:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.cake-toppings.com/?p=140#comment-1110</guid>
		<description>I came across the same &quot;problem&quot;. I don&#039;t know if it is really a problem but it IS making most of my cache writes register as expired.. and it makes using Cache a bit more of a headache.

Seems to be that when you READ a cache file it will check against two values to see if should be expired. First it will compare to the defined expiration... if you set one, ie:

Cache::write(&#039;filename&#039;, &#039;data&#039;, &#039;+1 day&#039;);

Then it ALSO checks against the DEFAULT expiration duration + current time. It is 3600 (1 hour) by default. 

Strange thing (to me) is that it is checking if cachetime (+1 day) is greater than time + duration (current time + 3600). If it is.. it is considered expired. So, if I write a cache that expires in +1 day.. and try to read that cache within 23 hours, it will be considered expired. 

I&#039;m still trying to wrap my head around this but so far a workaround seems to be if you set the default duration for your cache config to something longer than you typically use in your app.. like +1 month. Then, as long as you aren&#039;t caching anything longer than that, it will work as it had previously (and you can just write in the duration as your third param in Cache::write)</description>
		<content:encoded><![CDATA[<p>I came across the same &#8220;problem&#8221;. I don&#8217;t know if it is really a problem but it IS making most of my cache writes register as expired.. and it makes using Cache a bit more of a headache.</p>
<p>Seems to be that when you READ a cache file it will check against two values to see if should be expired. First it will compare to the defined expiration&#8230; if you set one, ie:</p>
<p>Cache::write(&#8216;filename&#8217;, &#8216;data&#8217;, &#8216;+1 day&#8217;);</p>
<p>Then it ALSO checks against the DEFAULT expiration duration + current time. It is 3600 (1 hour) by default. </p>
<p>Strange thing (to me) is that it is checking if cachetime (+1 day) is greater than time + duration (current time + 3600). If it is.. it is considered expired. So, if I write a cache that expires in +1 day.. and try to read that cache within 23 hours, it will be considered expired. </p>
<p>I&#8217;m still trying to wrap my head around this but so far a workaround seems to be if you set the default duration for your cache config to something longer than you typically use in your app.. like +1 month. Then, as long as you aren&#8217;t caching anything longer than that, it will work as it had previously (and you can just write in the duration as your third param in Cache::write)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Taras Kozlov</title>
		<link>http://www.cake-toppings.com/2009/03/19/cache-duration-and-configuration-tips/comment-page-1/#comment-1074</link>
		<dc:creator>Taras Kozlov</dc:creator>
		<pubDate>Thu, 02 Apr 2009 13:15:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.cake-toppings.com/?p=140#comment-1074</guid>
		<description>Charlie, 

Thank you again for your help. And you are right that we probably need to finish the conversation here.</description>
		<content:encoded><![CDATA[<p>Charlie, </p>
<p>Thank you again for your help. And you are right that we probably need to finish the conversation here.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: primeminister</title>
		<link>http://www.cake-toppings.com/2009/03/19/cache-duration-and-configuration-tips/comment-page-1/#comment-1073</link>
		<dc:creator>primeminister</dc:creator>
		<pubDate>Thu, 02 Apr 2009 13:13:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.cake-toppings.com/?p=140#comment-1073</guid>
		<description>File a ticket on trac.cakephp.org. Reference to my ticket and specify this. They will help you</description>
		<content:encoded><![CDATA[<p>File a ticket on trac.cakephp.org. Reference to my ticket and specify this. They will help you</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Taras Kozlov</title>
		<link>http://www.cake-toppings.com/2009/03/19/cache-duration-and-configuration-tips/comment-page-1/#comment-1072</link>
		<dc:creator>Taras Kozlov</dc:creator>
		<pubDate>Thu, 02 Apr 2009 13:11:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.cake-toppings.com/?p=140#comment-1072</guid>
		<description>Charlie, 

You probably won&#039;t believe in this, but according to my tests - cache works fine when defined right in the action, but doesn&#039;t work when defined in the core.php. Moreover, even if you initialize another storage engine right in the action - other ones will work fine. 

Btw, I used storage names in the read/write from the beginning.</description>
		<content:encoded><![CDATA[<p>Charlie, </p>
<p>You probably won&#8217;t believe in this, but according to my tests &#8211; cache works fine when defined right in the action, but doesn&#8217;t work when defined in the core.php. Moreover, even if you initialize another storage engine right in the action &#8211; other ones will work fine. </p>
<p>Btw, I used storage names in the read/write from the beginning.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: primeminister</title>
		<link>http://www.cake-toppings.com/2009/03/19/cache-duration-and-configuration-tips/comment-page-1/#comment-1065</link>
		<dc:creator>primeminister</dc:creator>
		<pubDate>Thu, 02 Apr 2009 07:38:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.cake-toppings.com/?p=140#comment-1065</guid>
		<description>@Taras: Sorry, my bad. It is working perfectly. I used it wrong. If you use  the config name for every read and write action it is wroking fine.
If you are not sure, make a testcase (or change my patch at https://trac.cakephp.org/ticket/6262 )</description>
		<content:encoded><![CDATA[<p>@Taras: Sorry, my bad. It is working perfectly. I used it wrong. If you use  the config name for every read and write action it is wroking fine.<br />
If you are not sure, make a testcase (or change my patch at <a href="https://trac.cakephp.org/ticket/6262" rel="nofollow">https://trac.cakephp.org/ticket/6262</a> )</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Taras Kozlov</title>
		<link>http://www.cake-toppings.com/2009/03/19/cache-duration-and-configuration-tips/comment-page-1/#comment-1058</link>
		<dc:creator>Taras Kozlov</dc:creator>
		<pubDate>Wed, 01 Apr 2009 21:23:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.cake-toppings.com/?p=140#comment-1058</guid>
		<description>Charlie, 

Thank you for your help in clarifying the issue.</description>
		<content:encoded><![CDATA[<p>Charlie, </p>
<p>Thank you for your help in clarifying the issue.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: primeminister</title>
		<link>http://www.cake-toppings.com/2009/03/19/cache-duration-and-configuration-tips/comment-page-1/#comment-1057</link>
		<dc:creator>primeminister</dc:creator>
		<pubDate>Wed, 01 Apr 2009 21:14:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.cake-toppings.com/?p=140#comment-1057</guid>
		<description>Taras: you were right. I made a ticket with a testcase patch: https://trac.cakephp.org/ticket/6262</description>
		<content:encoded><![CDATA[<p>Taras: you were right. I made a ticket with a testcase patch: <a href="https://trac.cakephp.org/ticket/6262" rel="nofollow">https://trac.cakephp.org/ticket/6262</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: primeminister</title>
		<link>http://www.cake-toppings.com/2009/03/19/cache-duration-and-configuration-tips/comment-page-1/#comment-1046</link>
		<dc:creator>primeminister</dc:creator>
		<pubDate>Wed, 01 Apr 2009 08:50:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.cake-toppings.com/?p=140#comment-1046</guid>
		<description>Interesting Taras... I will dive into that myself. If this is true, it is a bug.</description>
		<content:encoded><![CDATA[<p>Interesting Taras&#8230; I will dive into that myself. If this is true, it is a bug.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Taras Kozlov</title>
		<link>http://www.cake-toppings.com/2009/03/19/cache-duration-and-configuration-tips/comment-page-1/#comment-1045</link>
		<dc:creator>Taras Kozlov</dc:creator>
		<pubDate>Wed, 01 Apr 2009 08:49:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.cake-toppings.com/?p=140#comment-1045</guid>
		<description>When Cache::read calls FileEngine::read actual storage&#039;s settings aren&#039;t passed there (I understand that I probably missed something), but when I added a dump to the FileEngine::read method to show me the actual settings it&#039;s shown data the was defined in the _last_ file storage defined in core.php 

So, when it evaluates line #169 (that I explained above) it uses incorrect values.</description>
		<content:encoded><![CDATA[<p>When Cache::read calls FileEngine::read actual storage&#8217;s settings aren&#8217;t passed there (I understand that I probably missed something), but when I added a dump to the FileEngine::read method to show me the actual settings it&#8217;s shown data the was defined in the _last_ file storage defined in core.php </p>
<p>So, when it evaluates line #169 (that I explained above) it uses incorrect values.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: primeminister</title>
		<link>http://www.cake-toppings.com/2009/03/19/cache-duration-and-configuration-tips/comment-page-1/#comment-1044</link>
		<dc:creator>primeminister</dc:creator>
		<pubDate>Wed, 01 Apr 2009 08:39:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.cake-toppings.com/?p=140#comment-1044</guid>
		<description>@Taras: You read and write and set the cache config explicitly. SO how come that the order of the configs in core.php will be of any influence?</description>
		<content:encoded><![CDATA[<p>@Taras: You read and write and set the cache config explicitly. SO how come that the order of the configs in core.php will be of any influence?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

