I am using a wkwebview to display a URL, I need the site data and cache to deleted or not to save cache at all. I need it to load up a fresh page each time. I have tried several methods but none work.
@IBOutlet weak var webView: WKWebView!
@IBOutlet weak var searchBar: UISearchBar!
override func viewDidLoad() {
super.viewDidLoad()
searchBar.backgroundImage = UIImage() // removes border
let myURL = URL(string: "https://myURL.com")!
let myRequest = URLRequest(url: myURL)
webView.load(myRequest)
}
}
If you don't ever want caching try setting the NSURLRequest.CachePolicy to reloadIgnoringLocalAndRemoteCacheData when initialising the URLRequest.
e.g.
let request = URLRequest(url: myURL, cachePolicy: .reloadIgnoringLocalAndRemoteCacheData, timeoutInterval: 10)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With