Preventing WP Super Cache from caching if no Slimstat in HTML

I was struggling with an occasional loss of reported traffic by SlimStat, due to my pages being cached by WP Super Cache (which is not active for logged in users) but not having SlimStatParams & the slimstat JS-file in it. I tried changing different settings in Slimstat, but the problem still occurred. As I was not able to pinpoint the exact root cause, I ended up using this code snippet to prevent pages being cached by WP Super Cache;

add_filter('wp_cache_ob_callback_filter','slimstat_checker');
function slimstat_checker($bufferIn) {
  if ( strpos($bufferIn, "<html") && strpos($bufferIn, "SlimStatParams") === false ) {
	define("DONOTCACHEPAGE","no slimstat no cache");
	error_log("no slimstat = no cache");
  }
  return $bufferIn;
}

Changing the condition on line 3 allow one to stop caching based on whatever (not) being present in the HTML.