Smart cache manager