如何缓存图像和html文件在PhoneGap [英] How to cache images and html files in PhoneGap

查看:123
本文介绍了如何缓存图像和html文件在PhoneGap的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个方法来缓存图像和html文件在PhoneGap从我的网站。我计划,用户会看到网站没有互联网连接,因为它会与它。但是我只能看到有关sql数据存储的信息,但是如何存储图像(以后再使用)。

I need a way for cache images and html files in PhoneGap from my site. I'm planning that users will see site without internet connection like it will be with it. But I see information only about sql data storing, but how can I store images (and use later).

推荐答案

可能需要简单的离线操作不是那么容易。

Caching like you might need for simple offline operation is not exactly that easy.

您的第一个选项是缓存清单。它有一些限制(比如缓存的大小),但可能适用于你,因为它被设计成你想要的。

Your first option is the cache manifest. It has some limitations (like the size of the cache) but might work for you since it was designed to do what you want.

另一个选择是你可以存储内容在使用文件系统API的设备的磁盘上。这有一些缺点,如安全性和事实,你必须从路径/ url加载文件,这是不同于你通常可以从网站加载它。查看 hydra 插件的示例。

Another options is that you can store content on the disk of the device using the file system APIs. This has some drawbacks like security and the fact that you have to load the file from a path / url that is different than you might normally load it from on the web. Check out the hydra plugin for an example of this.

一个最后一个选项可能是存储在localStorage的东西(有利的是所有平台上的私人的好处),然后在需要时拉出它...这意味着base64的所有图像,所以这是一个相当大的偏离只是标准的缓存。

One final option might be to store stuff in localStorage (which has the benefit of being private on all platforms) and then pull it out of there when needed ... that means base64'ing all your images tho so that is a pretty big departure from just standard caching.

这篇关于如何缓存图像和html文件在PhoneGap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆