How do you clear/flush the WebView cache in a Cocoa app?
In particular, I would like to clear the cache of a local stylesheet.
I have tried the following to no avail:
// Tried this before loadRequest
[[NSURLCache sharedURLCache] removeAllCachedResponses];
// Also tried this before and after loadRequest
[webView.mainFrame reloadFromOrigin];
Even replacing the WebView with a new one still uses the cached stylesheet.
The other suggested solutions didn’t work for the local stylesheet (though they should work for remote resources).
I finally managed to solve this via the resourceLoadDelegate, by explicitly setting the cache policy:
Fun stuff.