Open kremizask opened 12 years ago
I tested on iOS 5.1.1 on both device and simulator, and NSURLCacheStorageAllowed
seems to be used for all UIWebView cache requests. How do you reproduce the issue?
I am testing on iOS 5.1 on device/simulator. I have a simple View Controller with a UIWebView. I first run the app with an internet connection and the response is being cached. Then I run the app without an internet connection and the UIWebView does not load the html response. The webView delegate method webView:didFailLoadWithError: is being called with error'The Internet connection appears to be offline.'
I have set the cache-control:max-age header. However, when I do the same tests using the iOS 4.3 simulator, the UIWebView presents the html response both in online and offline mode.
Just performed the very same test, worked well with iOS 5. I used this URL: http://rs.rhapsodyk.net/test/cache.html. Here is the test app: http://dl.dropbox.com/u/123346/SDURLCacheTest.zip.
Interesting... I if I change your url with mine it doesn't work so it must have something to do with the response headers. Since I am not allowed to give you the actual url so that you can see for your self, could you please take a look at the response headers and tell me if you can think of anything? http://dl.dropbox.com/u/16899725/headers.png .
The funny thing is that as I mentioned before, it works with iOS 4.3, meaning it works with SDURLCache.
You may try to add Last-Modified
header.
When the fallback to NSURLCache happens (iOS>5.0) caching for UIWebViews does not work. I assume it is because NSCachedURLResponse coming from an UIWebView has a storagePolicy set to NSURLCacheStorageAllowedInMemoryOnly as discussed here: https://github.com/rs/SDURLCache/pull/1 .