简体   繁体   English

离线移动Web应用程序存储

[英]Offline Mobile Web Application Storage

I am looking at writing a mobile web application with offline support, and would prefer to use the HTML5 offline capabilities instead of something like phonegap. 我正在考虑编写一个具有离线支持的移动Web应用程序,并且更愿意使用HTML5离线功能而不是像phonegap这样的功能。

A requirement of the app will be that it store 2 collections of different types of objects (lets call them Books and Authors) which, when online, it will download from the server. 该应用程序的一个要求是它存储2个不同类型对象的集合(我们称之为书籍和作者),这些对象在线时将从服务器下载。 If it didn't need to be offline then I'd be using some flavour of SQL tables or (preferably) a document-based DB to store these items, but having done some basic investigation I haven't found anything that feels "right" that works offline. 如果它不需要离线,那么我会使用一些SQL表格或(最好)基于文档的数据库来存储这些项目,但是做了一些基本的调查我没有发现任何感觉“正确” “离线工作。

My question is: what is the best strategy to store those items? 我的问题是:存储这些物品的最佳策略是什么? What I have considered so far: 到目前为止我所考虑的事情:

HTML5 localStorage - Seems to have relatively wide support but is limited to key value pairs, which would mean a slightly unpleasant data structure - maybe having a total-authors key and then a series of author-1....author-n key-document pairs. HTML5 localStorage - 似乎有相对广泛的支持,但仅限于键值对,这意味着一个稍微不愉快的数据结构 - 可能有一个total-authors密钥,然后是一系列author-1....author-n key-文件对。 This feels wrong to me - like I am trying to work around the intent of the storage. 这对我来说是错误的 - 就像我试图解决存储的意图。

CouchDb - I've worked with CouchDb quite a bit in the past so would love to use it or an equivalent, but "proper" CouchDb would require a native app (with which I have no experience), and the 2 in-browser equivalents I have seen don't quite seem to do the trick: Lawnchair doesn't seem to add much to the localStorage option and BrowserCouch doesn't appear to have had much activity recently (which always makes me wary). CouchDb - 我过去曾经使用过CouchDb,所以很想使用它或等效的,但是“适当的”CouchDb需要一个本机应用程序(我没有经验)和2个浏览器中的等价物我已经看到似乎没有做到这一点: Lawnchair似乎没有给localStorage选项增加太多,而且BrowserCouch最近似乎没有太多活动(这总是让我警惕)。

WebDb - Looks like it would be perfect...except it seems to be officially discontinued and doesn't look to be widely supported WebDb - 看起来它会很完美......除了它似乎正式停止并且看起来并没有被广泛支持

Gears - Discontinued 齿轮 - 已停产

IndexedDB - Limited browser support for now (at least according to caniuse) IndexedDB - 现在有限的浏览器支持(至少根据caniuse)

I'm convinced there must be something out there that does what I want, and I've just managed to somehow overlook it. 我确信必须有一些东西可以做我想要的东西,我只是设法忽视它。 Can anyone suggest the way this ought to be done (as opposed to a way it could be done)? 任何人都可以提出这应该做(而不是一个方式,它可以做)的方式吗?

There's no browser-native simple solution as far I know; 据我所知,目前还没有浏览器原生的简单解决方案; you'll have to either go with localStorage or develop for both WebDB and IndexedDB. 你必须要么使用localStorage,要么开发WebDB和IndexedDB。

But non-native you could use a abstraction layer like lawnchair (uses localStorage by default, plugins available for indexeddb, webdb, ...) or the one SO-user Gatapia wrote for picnet (uses indexeddb & webdb & gears) that you can find on github . 但是非本地的你可以使用像lawnchair那样的抽象层(默认情况下使用localStorage,indexeddb,webdb等可用的插件)或者是一个SO用户Gatapia为picnet编写的 (使用indexeddb&webdb&gears)你可以在github上找到

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM