Fix caching system with cache_limit enforcement