Fix a long-standing bug where some caches could grow larger than configured.