0

I have used SFSafariView to load a ‘HTTPS’ website but its taking way to long to load up each time upon button click. I remember when using the UiWebView a few years back on a tabbed application it would load the website first time when you get onto the web view controller but after the first load the load on that web view would be instant. Is there any way to load a website before bringing up that view or a way to load it on the first time but after that time it loads faster (using cache) ?

I have tried looking for tutorials and information online and have tried using the WKWebView and playing around with the SFSafariView, cannot find anything specific to functionality I would like. Any Help would be greatly appreciated.

Swifter
  • 73
  • 1
  • 14

1 Answers1

1

Try use cache policy.

let urlRequest = URLRequest(url: URL(string: "www.example.com")!, cachePolicy: .reloadRevalidatingCacheData, timeoutInterval: 15.0)
let wkWebView = WKWebView(frame: .zero)
wkWebView.load(urlRequest)
Lumialxk
  • 6,239
  • 6
  • 24
  • 47
  • Hi i tried that but it doesnt seem to make much difference, when i load the webViewController it loads the website each time which takes atleast 5-8 seconds. Is there a way i can pre-load the webview ( which is on the second viewController) from the first view controller, or have a way where the second view controller ( which contains the webview) is not dismissed. So when i nagivate to second view controller it loads the webview with the url and then i can do back to first controller without completly dismissing the second view controller so when i go back it doesnt have to reload the url. – Swifter Jul 27 '18 at 03:05