Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UIWebView caching failure for iOS>5.0 #34

Open
kremizask opened this issue May 15, 2012 · 5 comments
Open

UIWebView caching failure for iOS>5.0 #34

kremizask opened this issue May 15, 2012 · 5 comments

Comments

@kremizask
Copy link

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: #1 .

@rs
Copy link
Owner

rs commented May 15, 2012

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?

@kremizask
Copy link
Author

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.

@rs
Copy link
Owner

rs commented May 16, 2012

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.

@kremizask
Copy link
Author

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.

@rs
Copy link
Owner

rs commented May 16, 2012

You may try to add Last-Modified header.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants