Update cache.php

added logger and some error handling