I need to cache webview url on WKWebview. I'm able to do it using the below configuration
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
}
}
and while loading the webview I'm using the below code:
let request = URLRequest(url: self.url!, cachePolicy: .returnCacheDataElseLoad, timeoutInterval: 600)
self.webView.load(request)
Issue I'm facing right now is the cache is taking time on every launch. i.e on every launch webview is taking a lot of time to load, after one load it is loading fast.
What I need to achieve is once webview is loaded, it should load faster on consecutive loads.