my code looks like
if([[self cache] isEqualToNumber:[[NSNumber alloc] initWithInt:1]])
{
[[NSURLCache sharedURLCache] setDiskCapacity:4 * 1024 * 1024];
[[NSURLCache sharedURLCache] setMemoryCapacity:32 * 1024 * 1024];
[self setRequestObj:[NSURLRequest requestWithURL:loadUrl cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0]];
}
else [self setRequestObj:[NSURLRequest requestWithURL:loadUrl cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60.0]];
My else part does not work. Why is my UIWebView not ignoring my local cache?
Every time I visited a testsite my app does not load from the original source. He only load the index.html but the linked images only at first visit.
What's my issue?
The NSURLRequestReloadIgnoringLocalCacheData flag affects only that one request, not future requests. So this works as expected. If you want to disable other caching, the only way I know of to do that is by implementing an NSURLProtocol that intercepts the HTTP/HTTPS requests, modifies them in an identifiable way (e.g. adding a custom header), and then re-sends them. This is not for the faint of heart.
You're probably better off just purging the cache: How to clear UIWebView cache?