Optimize performance of cache all functionality