Reloads the current page,performing end-to-end revalidation using
cache-validating conditionals if possible.
但我不确定这究竟意味着什么.
解决方法
reloadFromOrigin()将Cache-Control和Pragma字段设置为no-cache,而简单的reload()仅导致设置max-age = 0的Cache-Control头字段.
为了解决这个问题,我查看了Header Field Definitions section of the HTTP 1.1 spec.第14.9.4节“缓存重新验证和重新加载控件”状态:
The client can specify these three kinds of action using Cache- Control request directives:
End-to-end reload
The request includes a “no-cache” cache-control directive or,for compatibility with HTTP/1.0 clients,“Pragma: no-cache”. Field names MUST NOT be included with the no-cache directive in a request. The server MUST NOT use a cached copy when responding to such a request.Specific end-to-end revalidation
The request includes a “max-age=0” cache-control directive,which forces each cache along the path to the origin server to revalidate its own entry,if any,with the next cache or server. The initial request includes a cache-validating conditional with the client’s current validator.Unspecified end-to-end revalidation
The request includes “max-age=0” cache-control directive,with the next cache or server. The initial request does not include a cache-validating
conditional; the first cache along the path (if any) that holds a cache entry for this resource includes a cache-validating conditional with its current validator.
从我对规范的阅读中,看起来reload()仅使用max-age = 0,因此可能会导致您获得所请求数据的缓存但经过验证的副本,而reloadFromOrigin()将强制获取新的副本来自原始服务器.
(这似乎与Apple的WKWebView中的两个函数的头文件/类参考文档相矛盾.我认为两者的描述应该交换 – 我已经向Apple提交了Bug Report / Radar 27020398,如果我听到的话会以任何一种方式更新这个答案从他们回来…)