I use the Magento block cache for the top navigation block. The problem is the block has to generate some urls for files in the skin directory that cannot be put into css files as the file names depend on category model data.
Now when I open magento using a secure connection (https://) the navigation block is fetched from the cache and is sent to the browser but with the http:// urls resulting in a warning in most browsers about unsecure elements on the page.
I'd like the have separat caches for secure and unsecure connections. The navigation block extends the class Mage_Catalog_Block_Navigation
and therefore has the following cache configuration:
$this->addData(array(
'cache_lifetime' => false,
'cache_tags' => array(Mage_Catalog_Model_Category:开发者_Python百科:CACHE_TAG, Mage_Core_Model_Store_Group::CACHE_TAG),
));
Hmmm simpler than I thought...
I tried overriding the method getCacheKey()
by appending a flag with the current security status but at first this was no success but after several cache purges this seems to work now:
public function getCacheKey()
{
$key = parent::getCacheKey();
$key .= Mage::app()->getStore()->isCurrentlySecure() ? '_S' : '_U';
return $key;
}
精彩评论