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

Disk caching of UIWebView resources on iOS 4.2 #1

Closed
wants to merge 1 commit into from
Closed

Disk caching of UIWebView resources on iOS 4.2 #1

wants to merge 1 commit into from

Conversation

kemenaran
Copy link
Contributor

Starting from iOS 4.2, all NSCachedURLResponse coming from an UIWebView have a storagePolicy set to NSURLCacheStorageAllowedInMemoryOnly (instead of NSURLCacheStorageAllowed in the previous iOS versions).

Of course, as SDURLCache honors the storagePolicy, it won't cache any of the UIWebView response to the disk.

In order to fix this, I implemented an option that force SDURLCache to cache requests with NSURLCacheStorageAllowedInMemoryOnly. This option is enabled by default when running on iOS >= 4.2 (and disabled otherwise).

It may impact performances (as the InMemoryOnly policy is always ignored, even when legitimate). Maybe there is a better way to hook into the UIWebView NSURLConnection or NSURLProtocol to fix this?

@rs
Copy link
Owner

rs commented Jan 25, 2011

I merged your commit with some refactoring. I also activated the option regardless of the iOS version because:
1/ it may lead to bugs only reproducible on certain version of iOS
2/ I think only UIWebView use memory only storage policy

Thanks for your valuable contribution.

This pull request was closed.
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

Successfully merging this pull request may close these issues.

2 participants