我的URLCache在Xcode模拟器中缓存URL,但不是在真实的设备上。我将代码范围缩小到以下示例:
if let urlCache = SessionManager().session.configuration.urlCache {
// Returns nil, because there's nothing in the cache
print(urlCache.cachedResponse(for: urlRequest))
// Put the URL in the cache
urlCache.storeCachedResponse(CachedURLResponse(response: response, data: responseData), for: urlRequest)
// URL should now be in the cache, but it's still nil!
print(urlCache.cachedResponse(for: urlRequest))
}我对此感到非常困惑。有什么想法吗?
发布于 2017-10-26 04:22:04
原来这个缓存正在被其他网络调用填充,空间不足。我们通过大幅增加缓存的大小来修复它。
https://stackoverflow.com/questions/45759289
复制相似问题