PhoneGap离线缓存json数据 [英] PhoneGap Offline Caching json data

查看:100
本文介绍了PhoneGap离线缓存json数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个Phonegap应用程序,并且打算将其设置为在脱机和联机模式下均可使用,其想法是从PHP服务器端脚本获取JSON数据并将其显示在应用程序中,这些数据包含文本,图像,所以我的问题是无论如何都可以设置动态缓存清单或其他方式,以便用户在脱机时可以看到已经加载的数据,例如缓存json结果本身或您可以帮助我解决的其他问题

I'm building a Phonegap application and i'm planning to set it to work in both Offline and Online mode, the idea is to get JSON Data from a PHP server side script and show it in the application, these data contains text, images so my question is is there anyway to set a dynamic cache manifest or any other way in a way that the user can see the already loaded data when he's offline, like caching the json result itself or anything else you can help me with

谢谢

推荐答案

在离线和在线模式下工作"是什么意思?用户是否只能查看用户创建的数据,或者他们也可以对其进行修改?使用清单来控制用户创建的数据的缓存是否正确?我以为您应该只将它真正用于缓存应用程序模板和代码.无论如何,我认为您可能需要一些可以对其进行更多控制的东西,例如基于WebSQL,IndexedDb或LocalStorage的东西.

What do you mean by "work in both Offline and Online mode"? Are the users able to only see the user created data or can they modify it too? Is it correct to use a Manifest to control caching of user created data? I would have thought you should only really use it for caching the application templates and code. In any case I think you'll probably need something that you can exert more control over, something based perhaps using WebSQL, IndexedDb or LocalStorage.

我已经解决了太多问题,并且已经以javascript(phonegap)<->服务器同步的形式提供了一种解决方案,该解决方案的工作方式类似于版本控制系统,但存在版本号和冲突解析度. GitHub页面上有一些非常出色的文档和演示 ,您甚至可以看到由 SkillsMatter/LondonAJAX ..目前仅基于JS/Node服务器,但我可能会做基于PHP的服务器,因为那是我的日常工作.如果您查看服务器代码,它很容易实现.

I have been working on the modify-it-too question for many months and have a solution in the form of javascript(phonegap) <-> server synchronization that works somewhat like a version control system, with version numbers and conflict resolution. There's some pretty great docs and demo on the GitHub page and you can even see a presentation courtesy of SkillsMatter / LondonAJAX.. Currently there is only a JS/Node based server but I will probably do PHP based server because that's my day job If you look at the server code it's pretty easy to implement.

顺便说一句,我将使用另一种方法来存储图像,为什么不下载它们并将其存储在

BTW I would use a different method to store the images, why not just download them and store them in a File, I don't know the storage limits, but I bet that is the way that Phonegap will let you get away with most.

这篇关于PhoneGap离线缓存json数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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