Question

I've trying to display cached php/javascript content on a UIWebview for a while but I haven't succeeded yet. It runs OK with static content, but as soon as I try to load dynamic content using javascript it fails.

I've tried several potential solutions: (ASIHTTPRequest, AFCache...) but none of them seems to work for me. I always end up hitting the wall again and again, there doesn't seem to be an easy way of getting this done.

Yesterday I was playing a bit with the simulator when I spotted a file called Cache.db placed at: $(HOME_DIRECTORY)/Library/Caches/(app_bundle_id)/ (schema here: https://gist.github.com/1305158)

I think they brought back on-disk cache storage in iOS5, but I can't find a way of using it. Every time I try it just displays the bare-bones html (no javascript files or images referenced from it are loaded), no matter the cache policy I use. However, the javascript and image files are being properly cached since I can see them when querying the database file.

Anyone has figured out how to take advantage of this new feature? Does anyone know how to reference those js files stored on the cache?

Thanks

Was it helpful?

Solution

Since iOS 5, NSURLCache stores files into your /Library/Caches director as a Cache.db, everything depends on your Cache Control in your headers, set your Cache Control using php:

header('Cache-Control: public');

More info here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top