<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Aldoblog &#187; time-since</title>
	<atom:link href="http://aldoblog.com/tag/time-since/feed/" rel="self" type="application/rss+xml" />
	<link>http://aldoblog.com</link>
	<description>Michael Alderete’s Weblog</description>
	<lastBuildDate>Wed, 23 May 2012 11:14:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Problem with caching plug-in</title>
		<link>http://aldoblog.com/2005/01/problem-with-caching-plug-in/</link>
		<comments>http://aldoblog.com/2005/01/problem-with-caching-plug-in/#comments</comments>
		<pubDate>Mon, 10 Jan 2005 19:05:37 +0000</pubDate>
		<dc:creator>Alderete</dc:creator>
				<category><![CDATA[About This Site]]></category>
		<category><![CDATA[caching]]></category>
		<category><![CDATA[staticize]]></category>
		<category><![CDATA[time-since]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://aldoblog.com/blog/421</guid>
		<description><![CDATA[I've run into a slight problem with the Staticize caching plug-in I was using to speed up WordPress on this site. It seems that $post->post_date isn't correctly calculated on cached entries, even when you put them "outside" the cached page, and this screws up the time display on individual entries.]]></description>
			<content:encoded><![CDATA[<p></p>	<p>I&#8217;ve run into a slight problem with the <a href="http://photomatt.net/2004/07/26/staticize-25/">Staticize caching plug-in</a> I was using to speed up WordPress on this site. It seems that $post-&gt;post_date isn&#8217;t correctly calculated on cached entries, even when you put them &#8220;outside&#8221; the cached page, and this screws up the time display on individual entries.</p>

	<p><span id="more-421"></span></p>

	<p>Here&#8217;s the details. On my permalinks pages, I display a relative publication time, e.g., &#8220;Posted 3 days 27 minutes ago&#8221;, using the <a href="http://binarybonsai.com/archives/2004/08/17/time-since-plugin/">Dunstan&#8217;s Time Since</a> plug-in from Binary Bonsai. This works fine when the Staticize plug-in is disabled, and it works fine when Staticize is enabled, but only the first time the page is displayed, i.e., when it&#8217;s <em>not</em> served out of the cache. However, upon reloading, the page is served from cache, and the relative time displayed changes to the time since midnight.</p>

	<p>Now, since this relative time will change, minute by minute, it has to be outside the cache, or it won&#8217;t update. Staticize has an easy way to accomplish this using simple tags. In my index.php page for WordPress, to display the relative time I have:</p>

	<p><code>Posted &lt;!--mclude timesince.php--&gt;&lt;?php require(&#39;timesince.php&#39;); ?&gt;&lt;!--/mclude--&gt; ago</code></p>

	<p>The timesince.php file is also pretty simple, just a quick calculation to emit the relative time:</p>

	<p><code>&lt;?php $entry_datetime = abs(strtotime($post-&gt;post_date) - (60*60*8)); 
echo time_since($entry_datetime); ?&gt;</code></p>

	<p>This technique tells the Staticize plug-in to process the include file every time, not just the first time. In theory, this would allow the relative timestamp to be calculated each time the page is served, and thus always be correct.</p>

	<p>But I think that when Staticize is enabled, and determines that a page is in the cache, $post isn&#8217;t fully set for that page, and so the value of $post-&gt;post_date is meaningless, or it actually has no value at all, and so the functions above just calculate from the current date.</p>

	<p>At any rate, for now the site doesn&#8217;t need caching to keep up, so I&#8217;ve turned off Staticize until I can decide if I care more about displaying the time since or about being ready for a traffic spike. <hr />Copyright &copy; 2012 by <strong><a href="http://aldoblog.com">Aldoblog</a></strong>. All rights reserved. This feed is provided for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. Please contact legal-2011@aldoblog.com so we can take action immediately.</p>]]></content:encoded>
			<wfw:commentRss>http://aldoblog.com/2005/01/problem-with-caching-plug-in/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

