【问题标题】:URLCache caches URL on Xcode simulator but not deviceURLCache 在 Xcode 模拟器上缓存 URL,但不在设备上
【发布时间】:2017-08-18 14:38:20
【问题描述】:

我的 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))
}

我对此感到非常困惑。有什么想法吗?

【问题讨论】:

  • 出于好奇,responseData 的大小是多少?你的urlCachediskCapacitymemoryCapacity 是什么?

标签: ios xcode afnetworking alamofire


【解决方案1】:

原来这个缓存被其他网络调用填充并且空间不足。我们通过显着增加缓存大小来修复它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-06-11
    • 2012-04-16
    • 1970-01-01
    • 2011-10-16
    • 2014-05-02
    • 2012-12-21
    • 2011-05-05
    相关资源
    最近更新 更多