##The problem:
When trying to cache a Stash embed or other post-processed Stash tag, ce_cache is caching only the placeholder for the post-processed tag.
http://devot-ee.com/add-ons/support/ce-cache/viewthread/9155
##Solution 1
Use process="start"
or process="inline"
instead, so the embed/tag is not post-processed:
{exp:ce_cache:it}
{stash:embed:my:embed process="inline"}
{exp:ce_cache:it}
##Solution 2
Ce_cache could use the same post processing trick when capturing the cached data:
{exp:ce_cache:it process="end"}
{stash:embed:my:embed}
{exp:ce_cache:it}
As a plugin is parsed later than the tags it encloses, when ce_cache gets around to cache the tagdata it looks like this:
{exp:ce_cache:it process="end"}
{f1621dfce8169c33bc9db7c18b6027042104227290}
{exp:ce_cache:it}
Ce_cache could replace the opening and closing tagpairs with placeholders, return that to the template, and save it's parameters for later:
{ce_cache:1t49cHY01Z5j4TT91fGfr1t49cHY01Z5j4TT91fGfr}
{f1621dfce8169c33bc9db7c18b6027042104227290}
{/ce_cache:1t49cHY01Z5j4TT91fGfr1t49cHY01Z5j4TT91fGfr}
$this->EE->session->cache['ce_cache']['__template_post_parse__']['1t49cHY01Z5j4TT91fGfr1t49cHY01Z5j4TT91fGfr'] = array(
'tagparams' => $this->EE->TMPL->tagparams
);
After the template_post_parse
hook has been run for Stash the template will look like this:
{ce_cache:1t49cHY01Z5j4TT91fGfr1t49cHY01Z5j4TT91fGfr}
The content of the Stash embed
{/ce_cache:1t49cHY01Z5j4TT91fGfr1t49cHY01Z5j4TT91fGfr}
So if a ce_cache extension is now triggered by the template_post_parse
hook, it can look for the placeholder pair it made earlier in the template and capture the content inside:
$starts_at = strpos($template, "{ce_cache:".$placeholder."}") + strlen("{ce_cache:".$placeholder."}");
$ends_at = strpos($template, "{/ce_cache:".$placeholder."}", $starts_at);
$this->EE->TMPL->tagdata = substr($template, $starts_at, $ends_at - $starts_at);
...and now combine that with the tagparams saved earlier for this placeholder key, you can run the appropriate method in ce_cache to cache the tagdata.
Thanks for the detailed write-up Mark! In the end, I was able to solve the issue by simply calling the template_post_parse hook for the processed content before caching it. That allowed Stash to clean up any placeholders that were left behind. :)