views:

30

answers:

1

I am considering caching an entire web page locally on the iphone, i.e. I want to provide a url and have the device download all the assets automatically.

ASIHTTPRequest offers a cache, but as far as I understand it will only cache whatever url you feed it. I wonder if anyone has implemented a caching mechanism that will parse the downloaded file and download any assets required, create the corresponding folder structure, etc.

Maybe there is a low level network approach that I am unaware of?

+1  A: 

The only good way to figure the resources referenced by a webpage is to load it into UIWebView. UIWebViewDelegate will be able to tell you all the resources that get loaded in the process. Approaches from there:

  • Hopefully you can then pull resource data out of NSURLCache
  • If not you'll have to re-download all files again for your own use
  • If forced to do that you could perhaps get cunning and stop the webview downloading any resources other than the HTML
Mike Abdullah