<?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>Nerdpress.org &#187; cache</title>
	<atom:link href="http://nerdpress.org/tag/cache/feed/" rel="self" type="application/rss+xml" />
	<link>http://nerdpress.org</link>
	<description>Just another WordPress site</description>
	<lastBuildDate>Mon, 30 Jan 2012 14:28:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>how to not cache the footer in magento</title>
		<link>http://nerdpress.org/2011/10/04/how-to-not-cache-the-footer-in-magento/</link>
		<comments>http://nerdpress.org/2011/10/04/how-to-not-cache-the-footer-in-magento/#comments</comments>
		<pubDate>Tue, 04 Oct 2011 03:10:45 +0000</pubDate>
		<dc:creator>Max Girkens</dc:creator>
				<category><![CDATA[ecommerce]]></category>
		<category><![CDATA[magento]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[footer]]></category>

		<guid isPermaLink="false">http://nerdpress.org/?p=1823</guid>
		<description><![CDATA[With some advanced scheduled-post-voodoo i successfully managed to publish this post already yesterday with some completely unrelated queries and no text. this was not intended &#8211; please accept my apologies :P Anyway: In the footer of my magento shop we might have a summary of the shopping cart, which i simply put in the footer.phtml [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p>With some advanced scheduled-post-voodoo i successfully managed to publish this post already yesterday with some completely unrelated queries and no text. this was not intended &#8211; please accept my apologies :P</p>
<p>Anyway: In the footer of my magento shop we might have a summary of the shopping cart,<br />
which i simply put in the footer.phtml template file:<br />
<span id="more-1823"></span></p>
<pre class="brush: php; title: ; notranslate">
&lt;?php if (Mage::getModel('checkout/cart')-&gt;getItemsCount() &gt; 0): ?&gt;
  &lt;div class=&quot;footer_cart_widget&quot;&gt;
    &lt;a href=&quot;/checkout/cart&quot; class=&quot;cart&quot;&gt;
      &lt;?php echo $this-&gt;__('Warenkorb') ?&gt;:&lt;br /&gt;
      &lt;span class=&quot;cart_meta&quot;&gt;
        &lt;?php echo Mage::getModel('checkout/cart')-&gt;getItemsCount() ?&gt;
        &lt;?php if (Mage::getModel('checkout/cart')-&gt;getItemsCount() == 1): ?&gt;
          Produkt:
        &lt;?php else: ?&gt;
          Produkte:
        &lt;?php endif; ?&gt;
        &lt;?php echo $this-&gt;helper('checkout')-&gt;formatPrice(Mage::getSingleton('checkout/cart')-&gt;getQuote()-&gt;getGrandTotal()); ?&gt;
      &lt;/span&gt;
    &lt;/a&gt;
  &lt;/div&gt;
&lt;?php endif; ?&gt;
</pre>
<p><a href="http://nerdpress.org/wp-content/uploads/2011/10/Bildschirmfoto-2011-10-04-um-21.21.05.png" rel="lightbox[post-1823]" title=""><img src="http://nerdpress.org/wp-content/uploads/2011/10/Bildschirmfoto-2011-10-04-um-21.21.05-300x146.png" alt="Bildschirmfoto-2011-10-04-um-21 21 05-300x146 in " width="300" height="146" class="alignnone size-medium wp-image-1846" /></a></p>
<p>This means we might need to disable the caching for the footer HTML block,<br />
so that my cart summary will stay dynamically generated.</p>
<p>This is how you can do it:</p>
<p>copy</p>
<pre class="brush: bash; title: ; notranslate">app/code/core/Mage/Page/Block/Html/Footer.php</pre>
<p>to</p>
<pre class="brush: bash; title: ; notranslate">app/code/local/Mage/Page/Block/Html/Footer.php</pre>
<p>and just comment out the following lines:</p>
<pre class="brush: php; title: ; notranslate">
//$this-&gt;addData(array(
//    'cache_lifetime'=&gt; false,
//    'cache_tags'    =&gt; array(Mage_Core_Model_Store::CACHE_TAG, Mage_Cms_Model_Block::CACHE_TAG)
//));
</pre>
<p>you could also put the cart values in the getCacheKeyInfo() method, but as this would result in caching a footer for any state of the shopping cart from my understanding, i don&#8217;t think it&#8217;s necessarily a good idea.</p>
<div class="plus-one-wrap"><g:plusone href="http://nerdpress.org/2011/10/04/how-to-not-cache-the-footer-in-magento/"></g:plusone></div>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://nerdpress.org/2011/10/04/how-to-not-cache-the-footer-in-magento/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Silverstripe &#8220;auto&#8221; flush cache</title>
		<link>http://nerdpress.org/2010/04/15/silverstripe-auto-flush-cache/</link>
		<comments>http://nerdpress.org/2010/04/15/silverstripe-auto-flush-cache/#comments</comments>
		<pubDate>Thu, 15 Apr 2010 08:20:57 +0000</pubDate>
		<dc:creator>Max Girkens</dc:creator>
				<category><![CDATA[CMS]]></category>
		<category><![CDATA[Silverstripe]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://nerdpress.org/?p=918</guid>
		<description><![CDATA[thereifixedit: Wenn man bei einem Silverstripe Projekt häufige Änderungen an verschachtelten Templates hat, kommt man, soweit ich weiss, nicht umhin an den Seitenaufruf anzuhängen um die Änderungen sichtbar zu machen. Weil ich gerade sehr häufig in der Situation bin, also jede Minute, hatte ich gehofft man könnte den Cache irgendwo abschalten. In der Richtung habe [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p><a href="http://thereifixedit.com">thereifixedit</a>:<br />
Wenn man bei einem <a href="http://silverstripe.org/">Silverstripe</a> Projekt häufige Änderungen an verschachtelten Templates hat,<br />
kommt man, soweit ich weiss, nicht umhin </p>
<pre class="brush: php; title: ; notranslate">
?flush=1
oder
?flush=all
</pre>
<p>an den Seitenaufruf anzuhängen um die Änderungen sichtbar zu machen.<span id="more-918"></span></p>
<p>Weil ich gerade sehr häufig in der Situation bin, also jede Minute, hatte ich gehofft man könnte den Cache irgendwo abschalten.<br />
In der Richtung habe ich aber nichts gefunden. </p>
<p>Es lohnt aber ggf. <strong>lokal</strong> den Parameter einfach immer zu setzen.<br />
Allzu langsam wird das ganze dadurch auch nicht.</p>
<p>also in der _config.php </p>
<pre class="brush: php; title: ; notranslate">
if ( strpos( $_SERVER[&quot;REQUEST_URI&quot;], 'admin' ) === false ) {
  $_GET[&quot;flush&quot;] = 1;
}
</pre>
<p>:D</p>
<p>ziemliche Krücke, aber hilft erstmal weiter.</p>
<p>Gibt es einen eleganteren Weg, den ich auf die Schnelle nicht gefunden habe?<br />
Oder liegt das nur an meinem Template Design dass ich das dauernd brauche? :)</p>
<div class="plus-one-wrap"><g:plusone href="http://nerdpress.org/2010/04/15/silverstripe-auto-flush-cache/"></g:plusone></div>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://nerdpress.org/2010/04/15/silverstripe-auto-flush-cache/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Der Symfony Cache, seine Keys und cache_namespace_callable</title>
		<link>http://nerdpress.org/2010/01/22/symfony-cache-key-und-cache_namespace_callable/</link>
		<comments>http://nerdpress.org/2010/01/22/symfony-cache-key-und-cache_namespace_callable/#comments</comments>
		<pubDate>Fri, 22 Jan 2010 15:41:42 +0000</pubDate>
		<dc:creator>Max Girkens</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[cache]]></category>

		<guid isPermaLink="false">http://nerdpress.org/?p=753</guid>
		<description><![CDATA[Symfony hat ja einen Cache. Der cached ggf (zB. mit der Option &#8220;with_layout: true&#8221;) auch eingebundene Partials. Sagen wir mal in einer Sidebar. Schön schnipselweise werden die gecached. Die haben dann auch jeweils einen CacheKey. Den sieht man auch wenn man für das dev environment den cache einschaltet in den kleinen bunten Info Kästen. Ein [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p><a href="http://www.symfony-project.org/">Symfony</a> hat ja einen <a href="http://www.symfony-project.org/book/1_2/12-Caching">Cache</a>.</p>
<p>Der cached ggf (zB. mit der Option &#8220;with_layout: true&#8221;) auch eingebundene Partials. Sagen wir mal in einer Sidebar.<br />
Schön schnipselweise werden die gecached.</p>
<p>Die haben dann auch jeweils einen CacheKey. Den sieht man auch wenn man für das dev environment den cache einschaltet in den kleinen bunten Info Kästen.</p>
<p>Ein Problem hat man aber dann, wenn jetzt ein Partial auf einer Seite je nach Parameter andere Dinge tun soll.<br />
Dann hat man schnell die eine Version aus dem Cache (die zuerst aufgerufene eben) und nicht mehr die mehreren Erscheinungsformen.<span id="more-753"></span><br />
Ist ja das gleiche Partial. Also lässt man das Cachen der Partials entweder weg, oder sorgt dafür dass die Dinger je nach Vorkommen einen anderen CacheKey kriegen. Und damit dann auch verschiedene Versionen gecached werden.</p>
<p>Dazu gibt es die Config Variable: &#8220;cache_namespace_callable&#8221; in der settings.yml.<br />
Da kann man eine Funktion / statische Methode angeben, die einen alternativen CacheKey generiert. </p>
<p>Die kriegt dann eine Instanz vom sfViewCacheManager übergeben, der normalerweise den CacheKey generiert.<br />
nur will man jetzt auf die original Methode zugreifen, und beispielsweise nur etwas anhängen, wird es etwas komplizierter.<br />
Ruft man die aus seiner Custom Callback Funktion auf, ended man im Loop, weil die ->generateCachekey() Methode dann wiederum die callback Funktion aufruft uswusw.</p>
<p>Gehen tut das aber schon, zB mit diesem simplen Trick:</p>
<pre class="brush: php; title: ; notranslate">

public static function GenerateMyCustomCacheKey( $internalUri, $hostName = '', $vary = '', $contextualPrefix = '', $sfViewCacheManager )
   {

  	//den Wert von sf_cache_namespace_callable speichern
  	$callableFunction =  sfConfig::get( 'sf_cache_namespace_callable' );

  	//sf_cache_namespace_callable auf false setzen
  	sfConfig::set( 'sf_cache_namespace_callable', false );

  	//jetzt die default methode auf unserer Instanz von sfViewCacheManager aufrufen
       //sf_cache_namespace_callable ist ja nun false, also passiert auch kein loop
  	$key = $sfViewCacheManager-&gt;generateCachekey( $internalUri, $hostName = '', $vary = '', $contextualPrefix = '' );

  	//sf_cache_namespace_callable wieder herstellen
  	sfConfig::set( 'sf_cache_namespace_callable', $callableFunction );

        //key manipulieren und zurückgeben
  	return $key . $myCustomSuffix;

  }
</pre>
<p>dann eben nur noch in der settings.yml der entsprechenden APP die callback Funktion angeben und voila &#8211; hat man custom cache keys und kann sich zB. x Versionen eines Partials erzeugen lassen.</p>
<pre class="brush: jscript; title: ; notranslate">
cache_namespace_callable: GenerateMyCustomCacheKey
</pre>
<p>oder </p>
<pre class="brush: jscript; title: ; notranslate">
cache_namespace_callable: myStaticHelperClass::GenerateMyCustomCacheKey
</pre>
<div class="plus-one-wrap"><g:plusone href="http://nerdpress.org/2010/01/22/symfony-cache-key-und-cache_namespace_callable/"></g:plusone></div>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://nerdpress.org/2010/01/22/symfony-cache-key-und-cache_namespace_callable/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

