@faintsignal
You where right!! ob_start(); was missing. It is probably not needed on a WAMP server.
But on a LAMP server it is needed.
The code now looks like:
<?php
ob_start();
function write_cache(){
$contents = ob_get_contents();
/// do something with contenst (like writing it..
}
$tpl_content = 'loooooong string'; // gets filled throughout the application
echo $tpl_content;
/// should be filling the cache
write_cache();
?>
And it works!!
Thanks!!!!