Fix a number of CI_Cache bugs

Fixes #4277
Supersedes #4474
Really fixes #4066
5 files changed