如何同步HTML5本地/webStorage和服务器端存储?
我目前正在寻找跨客户端 HTML5 localStorage 或 Web 存储和(可能是多个)服务器透明且自动同步和复制的解决方案-端存储(这里唯一的要求是在常规托管服务上安装应该简单且经济实惠)。
那么,您是否有过使用此类库/技术的经验,这些库/技术提供数据存储,可自动执行客户端-服务器存储同步并允许数据离线或在线或两者都可用?我认为这是支持离线模式的 Web 应用程序的一个相当常见的场景......
Possible Duplicate:
Best way to synchronize local HTML5 DB (WebSQL Storage, SQLite) with a server (2 way sync)
I'm currently seeking solutions for transparently and automatically synchronizing and replicating across the client-side HTML5 localStorage or web storage and (maybe multiple) server-side storage(s) (the only requirement here that it should be simple and affordable to install on a regular hosting service).
So do you have any experience with such libraries/technologies that offer data storage which automate the client-server storage synchronization and allow data to be available either offline or online or both? I think this is a fairly common scenario of web applications supporting offline mode...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Firebase 将此功能作为服务提供。
另一种选择是 Parse。
Firebase offers this functionality as a service.
Another alternative is Parse.
这取决于你想要什么。 http://hacks.mozilla 有一个很棒的教程可以帮助您入门。 org/2010/01/offline-web-applications/ 除非你想做一些复杂的事情,否则你不应该需要那么多的框架来为你做这件事。我想您可以使用 jQuery 在客户端上保存几行代码。您基本上希望在存储中保留最后一次对存储进行更改的时间、最后一次更新服务器的时间的记录,并使用在 XHR 中发送编码为 JSON 的 localStorage 变量(或者只是本地存储的位)商店您要发送)。然后,在服务器上,您可以解码 JSON 并对其执行您想要的操作,处理它或仅使用 PHP 的序列化将其转储到数据库。
如果您有什么特别的想法,请提及。
It kind of depends on what you want. There is a great tutorial to get you started at http://hacks.mozilla.org/2010/01/offline-web-applications/ Unless you want to do something complicated, you should not need that much of a framework to do it for you. I guess you could save a few lines of code on the client using jQuery. You basically want to keep in your store a record of when the last change was made to the store, when the last update was to the server, and use send the localStorage variable encoded as JSON in an XHR (or just the bit of the local store you want to send). Then, on the server, you can decode the JSON and do what you want with it, processing it or just using PHP's serialize to dump it to a database.
If you have something particular in mind, do mention it.
这个问题非常相似。
在那里,“快速连接” - http://quickconnect.pbworks.com/Using-Enterprise-Synchronization
推荐我个人最喜欢的“persistenceJS” - https://github.com/zefhemel/persistencejs。
一旦我收集了个人经验,我就会更新这篇文章。
this question is rather similar.
There, 'quick connect' - http://quickconnect.pbworks.com/Using-Enterprise-Synchronization
and my personal favorit 'persistenceJS' - https://github.com/zefhemel/persistencejs are recommended.
As soon as I gather personal experience, I'll update this post.
我刚刚发现了一个相当新的框架,它就是这样做的:Impel.inTouch。它的模式定义看起来有点不方便,但绝对值得一试。
I just found a quite new framework which does just that: Impel.inTouch. Its schema definition seems a bit inconvenient, but definitely worth a try.