Refreshing the cache like that works well, however, you are refreshing the entire cache. Try replacing your $modx->cacheManager->refresh() with the following. It will reduce load times and speed the refresh. It will also not affect the entire site.
if(!empty($modx->resource))
$modx->cacheManager()->refresh(array(
'auto_publish' => array('contexts' => array($modx->context->key)),
'context_settings' => array('contexts' => array($modx->context->key)),
'resource' => array('contexts' => array($modx->context->key), 'ids'=> array($modx->resource->get('id'))),
));
else
$modx->cacheManager()->refresh();
This will target the Resource (if we correctly have one, which we should). If we don't have one, it has a nice fallback. Additionally, it keeps in line with auto_publishing if this is used on your site. You may remove the first array ('auto_publish') if you are not using it.
Note: This targets the Resource, under the assumption that the Resource was the issue. If this does not keep it fixed, I can add a line which targets the Snippet too.
[ed. note: fuzzicallogic last edited this post 11 years, 8 months ago.]