我需要在WKWebview上缓存Webview URL。我可以使用以下配置做到这一点
var webViewConfiguration:WKWebViewConfiguration {
get {
// Create WKWebViewConfiguration instance
let webCfg:WKWebViewConfiguration = WKWebViewConfiguration()
// Configure the WKWebViewConfiguration instance with the WKUserContentController
webCfg.userContentController = userContentController
webCfg.websiteDataStore = WKWebsiteDataStore.default()
webCfg.processpool = Processpool.shared.processpool
return webCfg
}
}
,并且在加载网络视图时,我使用以下代码:
let request = URLRequest(url: self.url!,cachePolicy: .returnCacheDataElseLoad,timeoutInterval: 600)
self.webView.load(request)
我现在面临的问题是每次启动时缓存都需要时间。也就是说,每次启动Webview都需要花费很多时间来加载,一次加载后加载速度很快。
我需要实现的是,一旦加载了Webview,它在连续加载时应加载得更快。