-
- alexandru.topliceanu

-
Total Posts: 8
Joined: 2011-01-11
|
Hi everyone,
I am building a custom module that exposes some js variable of the page through a block template loaded in each page in the footer.
These variables change depending on the “type” of the page, but magento caches the output of the block, so the variables don’t change.
I need to programatically ensure that the html output of the block is not cached by magento. I can’t force the buyers of my module to disable all block cache on their store
I have found a solution to enable block caching( ?!?! caching is enabled by default ) and adapted it to serve my purposes, but it doesn’t seem to work.
class Namespace_Block_Blablabla extends Mage_Core_Block_Template {
// prevent caching of block's output public function getCacheKey(){ return $this->_getSqPageType() ; // this can be one of the following "product" | "checkout" | "confirmation" | "normal page" } public function getCacheLifetime(){ return 1 ; // smalles cache time possible, i want to disable it completely but i cant find a solution } public function getCacheTags(){ return array( Mage_Catalog_Model_Product::CACHE_TAG ) ; // i don't know what this does } public function __construct() { parent::__construct() ;
//should prevent caching of block's output, some solutions i found online say this is not needed, it doesn't work either way $this->addData( array( 'cache_lifetime'=> $this->getCacheLifetime() , 'cache_tags' => $this->getCacheTags() , 'cache_key' => $this->getCacheKey() )) ; }
It is really important that i fix this as we need to release this module as soon as posible
Thanks for your feedback,
Alex
|