WKWebView loading for a long time... Can I force WKWebView to work offline or with cache only?

Viewed 177
  • I have one wkwebview which is supposed to work offline. Because all of its content are downloaded files.
  • However, when the internet is not good, and just in this case, the webView loads for too long. 5, 10 seconds, or more. When the internet is good, or when there is no internet, this webView works offline.
  • From what I've been seeing, it's not going to be possible to do this WKWebview to work offline or just with cache.

Do you know if I can force a WKWebView to work offline?

This is my webView initialization code:

    lazy var webView: WKWebView = {
        let config = WKWebViewConfiguration()
        let userContentController = WKUserContentController()
        userContentController.add(self, name: "analyticsHandler")
        config.userContentController = userContentController
        config.dataDetectorTypes = []
        let webView = WKWebView(frame: viewWebView.frame, configuration: config)
        webView.navigationDelegate = self
        webView.uiDelegate = self
        webView.scrollView.bounces = false
        return webView
    }()
0 Answers
Related