I have loaded the url in webview
, loading is successful but whenever I hit again its show two url in cache and again its show three url etc. it means it continues to maintain the stack. I am using a lot of method but not working properly.
These are following what i am trying till now.
1.
[[NSURLCache sharedURLCache] removeCachedResponseForRequest:NSURLRequest];
[[NSURLCache sharedURLCache] removeAllCachedResponses];
for(NSHTTPCookie *cookie in [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies]) {
if([[cookie domain] isEqualToString:someNSStringUrlDomain]) {
[[NSHTTPCookieStorage sharedHTTPCookieStorage] deleteCookie:cookie];
}
}
2.
int cacheSizeMemory = 4*1024*1024; // 4MB
int cacheSizeDisk = 32*1024*1024; // 32MB
NSURLCache *sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:cacheSizeMemory diskCapacity:cacheSizeDisk diskPath:@"nsurlcache"];
[NSURLCache setSharedURLCache:sharedCache];
3.
NSURLCache *sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:0 diskCapacity:0 diskPath:nil];
[NSURLCache setSharedURLCache:sharedCache];
[sharedCache release];
4.
-(void) viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
[self.webView removeFromSuperview];
self.webView.delegate = nil;
self.webView = nil;
}
5.
[[NSURLCache sharedURLCache] setDiskCapacity:0];
[[NSURLCache sharedURLCache] setMemoryCapacity:0];
6.
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[self.webView stopLoading];
}
- (void) stopLoading {
[self.webView stopLoading];
self.webView.delegate = nil;
NSBundle *mainBundle = [NSBundle mainBundle];
NSURL *homeIndexUrl = [mainBundle URLForResource:@"Home" withExtension:@"html"];
NSURLRequest *urlReq = [NSURLRequest requestWithURL:homeIndexUrl];
[self.webView loadRequest:urlReq];
[EALoaderView hideLoaderForView:self.view animated:YES];
[self.webView loadHTMLString:html baseURL:nil];
}
I have also try from these following Answer.
2.NSURLProtocol isn't asked to load after YES response to canInitWithRequest
4.How to delete the cache from UIWebview or dealloc UIWebview
5.How to clear UIWebView cache?
I am doing a lot of R&D but not found the exact solution to resolve these things.
Thanks.