TL;DR
Can/should cache tags in Magento be dynamic?
Background
I'm creating a CMS integration from an external CMS into Magento. The data is stored in Elasticsearch in AWS. I have a custom controller which the page's URL is rewritten to, which uses the URL as a key and loads the data from a custom block I created called content/dynamic
.
Now I want to add block caching to it.
I know that the pertinent settings here are the cache tags and the cache key.
I'm thinking of using Mage_Cms_Model_Block::CACHE_TAG
as well as the store as base cache tags, then adding a custom cache tag e.g. Me_Content_Model_Dynamic::CACHE_TAG
, and the appropriate <global><cache><types>
entry for that so that I can clear all cached dynamic content from the Cache Management screen in Magento admin.
One of the features I need to implement is to be able to refresh content caches for the content/dynamic
block for a specific CMS page, as well as any content blocks underneath it.
Specifics
I'm thinking of adding another cache tag that is dynamic, e.g. dynamic_content_hashofURLhere
to each page's instance of content/dynamic
and all child blocks of it, so that I can easily identify dynamic page's cache entries for all content relating to a certain page.
Question
Is this the right way to use the cache tags?
It seems to me to be an easy way to target and invalidate a whole page worth of block cache entries for a page (no matter how many there are) without having to construct the cache key for each content block in the page and invalidate them individually.
Are dynamic cache tags used in the Magento code base already?
Is this best practice?
For clarity - I don't want to be able to clear any of the dynamic cache tags from the Cache Management page. I'd want to do this programatically. From the Cache Management page I'd only target a static cache tag that I add separately from this dynamic one.