How to clean up unused cache variables?

Automatically? No.

This (old) feature request might be of interest though since it would basically end up tracking cache variables anyways. It could be extended to track non-advanced variables that aren’t used at all (though it’d likely be an extension).