I sent 92merc the following change to test and it seems to work now.
// $html = preg_replace("/\.png\?(.+?)/" , ".png " , $html); // cut off random numbering of png
// $html = preg_replace("/\.jpg\?(.+?)/" , ".jpg " , $html); // cut off random numbering of jpg
// $html = preg_replace("/\.gif\?(.+?)/" , ".gif " , $html); // cut off random numbering of jpg
$html = preg_replace("/\.png\?[^\"]+/" , ".png" , $html); // cut off random numbering of png
$html = preg_replace("/\.jpg\?[^\"]+/" , ".jpg" , $html); // cut off random numbering of jpg
$html = preg_replace("/\.gif\?[^\"]+/" , ".gif" , $html); // cut off random numbering of jpg
The previous code was just replacing the "?" character in the URL with a space, which then led to the weird file name for the cache. The idea with the changed code is to remove the "?" and everything beyond until a quote mark is reached.