Make cache clearing command a little more robust