Fix stream issue in caching