I have created an HTML page. From my iPhone app I am using that URL in my UIWebView.
Here I want to set a code in my HTML, in which I can tell UIWebView not to use cache. Or I want to tell URL not to use cache.
If I am not able to explain you correctly, free to ask me.
Clean the HTML document by removing all content
[webview stringByEvaluatingJavaScriptFromString:@"document.body.innerHTML='';"];
Or Flush all cached data like bellow..
[[NSURLCache sharedURLCache] removeAllCachedResponses];
For more information see this blog UIWebView-secrets-part
I assume you want to disable cache by looking at an info on html or url. I suggest you to place this info in HTML between unique tags. You could parse it using string operations after.
If you are using url you should use something like query string.
Finally disabling cache is done by
[[NSURLCache sharedURLCache] removeAllCachedResponses];
[[NSURLCache sharedURLCache] setDiskCapacity:0];
[[NSURLCache sharedURLCache] setMemoryCapacity:0];
However this code disables cache for good. If you want to enable it again you should set disk capacity and memory capacity to a higher value.
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