如何将离线web应用程序(HTML+JS+CSS)与服务器同步?

时间:2022-10-31 18:34:15

Do I need to implement my own sync methods in order to make an offline web app (html+css+js) stay up to date with changes made on the server (and viceversa)? I'm using MySQL on the server side.

我是否需要实现自己的同步方法,以使离线web应用程序(html+css+js)跟上服务器(和viceversa)上的更改?我在服务器端使用MySQL。

I read Two-way sync between iPhone application and web application with some pointers but I think they're talking about native applications when they mention CFUUIDCreate and I wander if this is possible for the Web.

我用一些指针在iPhone应用程序和web应用程序之间读到双向同步,但是我认为当他们提到CFUUIDCreate的时候,他们是在说本地应用程序,我想这对于web来说是否可能。

Does someone have some code to share or maybe can point me in the right direction?

是否有人有一些代码可以分享,或者也许可以指向正确的方向?

Thank you!

谢谢你!

P.S.: I hope my english is not that rusty ;)

注:我希望我的英语没有那么生疏。

2 个解决方案

#1


2  

To store static contents on the client-side, as Jethro Larson said, the Application Cache Manifest is the way to go to cache the static contents of your website (HTML, CSS, JS and images).

如Jethro Larson所说,要在客户端存储静态内容,应用程序缓存清单是缓存网站静态内容(HTML、CSS、JS和图像)的方法。

To handle dynamically generated contents offline, you can use javascript templates. There are several solutions for this.

要离线处理动态生成的内容,可以使用javascript模板。有几种解决方法。

To sync the two databases, there is a project called persistence.js (persistencejs.org) which is a javascript library which offers a unique API to work with WebSQL databases, Local Storage, etc. They have a plugin for this library called persistence.sync (persistencejs.org/plugin/sync) which syncs the remote database with the server's one. It consists of POST and GET requests to a specific url that you can configure (for example yourapp.dev/sync). They have an example back-end written in node.js and here is one for Rails. It's simple to understand and persistence.sync is well documented.

要同步两个数据库,有一个项目叫做持久性。js (persistencejs.org)是一个javascript库,它提供一个独特的API来处理WebSQL数据库、本地存储等。同步持久化(sync persistences.org/plugin/sync),将远程数据库与服务器的数据库同步。它由POST和GET请求到您可以配置的特定url(例如您的app.dev/sync)组成。他们有一个用node编写的后端示例。这是Rails的一个例子。理解和坚持很简单。同步是有据可查的。

#2


0  

Look at the offline cache:
http://www.webreference.com/authoring/languages/html/HTML5-Application-Caching/
http://www.google.com/search?q=offline+cache+html5
http://www.slideshare.net/search/slideshow?q=offline+cache

查看离线缓存:http://www.webreference.com/authoring/languages/html/html5 - application caching/ http://www.google.com/search?q = http://www.slideshare.net/search/slideshow?q=offline html5离线缓存+ + +缓存

#1


2  

To store static contents on the client-side, as Jethro Larson said, the Application Cache Manifest is the way to go to cache the static contents of your website (HTML, CSS, JS and images).

如Jethro Larson所说,要在客户端存储静态内容,应用程序缓存清单是缓存网站静态内容(HTML、CSS、JS和图像)的方法。

To handle dynamically generated contents offline, you can use javascript templates. There are several solutions for this.

要离线处理动态生成的内容,可以使用javascript模板。有几种解决方法。

To sync the two databases, there is a project called persistence.js (persistencejs.org) which is a javascript library which offers a unique API to work with WebSQL databases, Local Storage, etc. They have a plugin for this library called persistence.sync (persistencejs.org/plugin/sync) which syncs the remote database with the server's one. It consists of POST and GET requests to a specific url that you can configure (for example yourapp.dev/sync). They have an example back-end written in node.js and here is one for Rails. It's simple to understand and persistence.sync is well documented.

要同步两个数据库,有一个项目叫做持久性。js (persistencejs.org)是一个javascript库,它提供一个独特的API来处理WebSQL数据库、本地存储等。同步持久化(sync persistences.org/plugin/sync),将远程数据库与服务器的数据库同步。它由POST和GET请求到您可以配置的特定url(例如您的app.dev/sync)组成。他们有一个用node编写的后端示例。这是Rails的一个例子。理解和坚持很简单。同步是有据可查的。

#2


0  

Look at the offline cache:
http://www.webreference.com/authoring/languages/html/HTML5-Application-Caching/
http://www.google.com/search?q=offline+cache+html5
http://www.slideshare.net/search/slideshow?q=offline+cache

查看离线缓存:http://www.webreference.com/authoring/languages/html/html5 - application caching/ http://www.google.com/search?q = http://www.slideshare.net/search/slideshow?q=offline html5离线缓存+ + +缓存