I subclassed NSURLCache
, and overwrote cachedResponseForRequest
, and changed the shared cache to my own cache object, to intercept every url request made by a UIWebView
. It works perfectly at the first time, when the URL loaded into the UIWebView
, it intercepts everything (css, jpg, etc). But when I try to load the same URL (eg. index.html), the cachedResponseForRequest
method won't be called. If then I try with a different URL it works perfectly again.
I tried to modify the request's cachePolicy to every possible values, but nothing helped.
Finally I found a solution: after every URL request, you have to release all the UIWebViews, and re-create them before the next request. IMPORTANT: every release should occur before the new allocs.