3

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.

J. Steen
  • 15,470
  • 15
  • 56
  • 63
Helen voy
  • 41
  • 4
  • 1
    See if [this helps](http://stackoverflow.com/questions/9744644/uiwebview-without-cache) -- duplicate if you ask me. – Chris Jan 09 '13 at 09:10

2 Answers2

3

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

Paras Joshi
  • 20,427
  • 11
  • 57
  • 70
1

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.

Can Leloğlu
  • 271
  • 1
  • 4
  • 11
  • I want to do this from server side. I want to do a code in my HTMl file. So suggest me a HTML solution/code. – Helen voy Jan 09 '13 at 10:02