原文链接 今天同事反应H5游戏资源更新了,但是iOS有缓存没有同步还是显示的原来的数据。今天研究了一下,收获颇多,分享给大家。 WKWebView默认缓存策略 下图是 苹果官方文档 提供的默认缓存策略(NSURLRequestUseProtocolCachePolicy)的流程图。这个图有点坑,容易让人误解,后面详细说。 默认缓存策略图(来源苹果官方) 官方文档上是这样描述的: For the HTTP and HTTPS protocols, NSURLRequestUseProtocolCachePolicy performs the following behavior: 1. If a cached response does not exist for the request, the URL loading system fetches the data from the originating source. 2. Otherwise, if the cached response does not indicate that it must be revalidated every time , and if the cached response is not stale (past its expiration date), the URL loading system returns the cached response. 3. If the cached response is stale or requires revalidation, the URL loading system makes a HEAD request to the originating source to see if the resource has changed. If so, the URL loading system fetches the data from the originating source. Otherwise, it returns the cached response. 官方文档说, 缓存不存在直接请求。 缓存存在,且缓存response头没有指明每次必须校验资源...