Phonegap 和离线缓存
我一直在尝试 Phonegap,如果您已经了解网络编程,我真的很喜欢制作电话应用程序的简单性。
我正在为一个网站制作一个应用程序,以便在新帖子上线时可以轻松关注。
我抓取提要并将其保存到本地存储, 本地存储
但是应该如何我缓存图像?
让您的应用程序离线友好的最佳方法是什么?
这是这样做的方法吗? HTML5 缓存宣言
问候, 凯文
I have been trying out Phonegap and i really love who simple it is to make Phone Apps, if you already know webprogramming.
I am making a app for a website, to make it easy to follow when new posts are online.
I grab the feed and save it to localstorage,
localstorage
but how should i cache images?
What are the best way to make your app offline friendly?
Is this the way to do it?
HTML5 caching manifesto
Regards,
Kevin
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不建议对 Web 应用程序使用 html5 缓存清单,除非您有一个已知的要缓存的图像列表,并且几乎不会改变,但在这种情况下,我建议您将文件本地添加到您的 PhoneGap 应用程序源中。
为了在phonegap应用程序中缓存图像,我创建了这个库:imgcache.js。它将图像存储到文件系统中(我想数据库应该更慢并且可用的磁盘空间更小)。如果您查看示例,您会发现它还可以检测图像何时无法加载(当您离线或服务器响应超时时),并自动将其替换为缓存的版本。
I don't recommend using html5 cache manifest for a web app, unless you have a known list of images to cache that will hardly change, but in that case I would advise you to add the files locally into your phonegap application source.
In order to cache images in phonegap applications I created this library: imgcache.js. It stores images into the filesystem (db should be slower and has smaller disk space available I suppose). If you check out the examples you will see it can also detect when an image fails to load (when you're offline or the server response times out) and replaces it automatically with the cached version.