Adding items to Cache Storage Management
-
13-12-2019 - |
Question
I'm using FPC with redis. I'd like to be able to flush the homepage or category pages from this page. How to I add these items to the Cache Storage Management? Hole punching? But how do I link the hole punching to the Cache Storage Management?
Solution
the items shown there are the cache items available. Since homepage and category pages are in FPC you can't display them separately.
This would require you to add a custom cache item.This tutorial explains how. Basically you need to define it in a custom modules config.xml
<global>
<cache>
<types>
<[custom_cache_name]module="[namespace]_[module]" translate="label description">
<label>Custom cache</label>
<description>A custom cache</description>
<tags>[CUSTOM_CACHE_TAG]</tags>
</[custom_cache_name]>
</types>
</cache>
</global>
and then write an observer that displays and one that saves the output of a whole page to that cache
Fetching it would be something like
$isActive = Mage::app()->useCache('[namespace]_[module]');
if ($isActive) {
// Cache is active
$cacheId = 'YOUR_CACHE_' . Mage::app()->getStore()->getId() . '_homepage';
if ($cacheContent = Mage::app()->loadCache($cacheId)) {
return $cacheContent;
}
}
// if not active or no content render page as normal
But stuff like normal FPC hole punching etc is missing here. It would basically require you to completely rebuild an FPC module.
Another option would be to find a way to check which cache IDs are homepage or category page and make a script that removes those with
Mage::app()->removeCache([some_cache_id]);