开发者

Store & retrieve data from cache in Iphone

开发者 https://www.devze.com 2023-01-27 13:46 出处:网络
I have an app in which I want to store the pages (In WebView) navigated once in the cache(IPhone). So that if the same page is accessed again it should come from cache & not from server.

I have an app in which I want to store the pages (In WebView) navigated once in the cache(IPhone).

So that if the same page is accessed again it should come from cache & not from server.

If a new p开发者_如何学Pythonage is accessed it will come from server.

Any help/tutorial/suggestion(with some sample code) please.


The behavior you're looking for already happens by default, assuming the cache headers are set correctly on the server side. Even then, though, the size of the cache is quite limited.

You can take a look at this post on creating a custom cache for UIWebView. It isn't exactly what you're looking for, but it will give you what you need to create your own cache that works regardless of what the cache headers from the server say, and with a much more generous size.


check out the ProxyingUIWebView project:

... started with a root web page, parsed it to find the urls of external resources, then downloaded and cached each one. When the process was finished, you could take the locally cached content and display it in the webview.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号