implement usage of TCA instead of manually filled configuration arrays, and I'm not sure, that calling substituteMarkerArray for every page before or after caching is good idea - maybe, there is a faster way for marker replacements. But anyway I can send the ext to you, if you wish, and you may use it as base for your task.