iOS 5 中 NSURLCache 的磁盘存储?
我尝试在 UIWebview 上显示缓存的 php/javascript 内容有一段时间了,但还没有成功。它对于静态内容运行正常,但是一旦我尝试使用 javascript 加载动态内容,它就会失败。
我已经尝试了几种可能的解决方案:(ASIHTTPRequest、AFCache...)但它们似乎都不适合我。我总是一次又一次地碰壁,似乎没有一个简单的方法可以完成这件事。
昨天,我在玩模拟器时,发现一个名为 Cache.db 的文件位于:$(HOME_DIRECTORY)/Library/Caches/(app_bundle_id)/(此处的架构:https://gist.github.com/1305158)
我认为他们带回了磁盘缓存存储iOS5,但我找不到使用它的方法。每次我尝试时,无论我使用什么缓存策略,它都只显示基本的 html(没有加载从中引用的 JavaScript 文件或图像)。但是,JavaScript 和图像文件已正确缓存,因为我在查询数据库文件时可以看到它们。
有人知道如何利用这个新功能吗?有谁知道如何引用存储在缓存中的那些js文件?
谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从 iOS 5 开始,
NSURLCache
将文件作为 Cache.db 存储到您的/Library/Caches
目录中,一切都取决于标头中的缓存控制,使用 php 设置缓存控制:更多信息这里。
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:More info here.