Offline mode Rails app

Asked

Viewed 373 times

8

In a new endeavor, I need a simple application to stay working if the internet connection is lost. Can someone explain to me how to do this?

I had thought to use HTML5’s persistence features in case of loss of connection, and somehow I still don’t know, to do a synchronization between the server and client databases when the connection is recovered. But here’s the question. How to do this using Rails?

I found some examples, but with static files referenced in the Html5 cache manifest... I don’t know if it would be the same in Rails. I haven’t tested it yet :(

Any idea?

  • 4

    This cache manifest is for the pages themselves (HTML/CSS/JS) to continue working if the connection drops. You’ll need this also. As for a bank that keeps running offline, perhaps the Pouchdb serve for what you are wanting (source: that comment by Gypsy Morrison Mendez in a related question). I never used, but it seems to do exactly what you want: use offline in the browser and sync when online.

  • 1

    It is a good question, in the company where I work we are thinking about it too, but so far the only alternative found was to rewrite the system as a js application.

  • Thought this Railscast screencast might help you ! Link to the screencast

1 answer

6


HTML5 Application Cache as far as I know is quite complex and therefore can be a headache to implement.

My suggestions:

  • use Pouchdb as already suggested here (especially if you use a Nosql database, since Pouchdb can automatically sync).
  • Another option that might be more browser-friendly would be to use localForage developed by Mozilla that allows you to save data offline to a common interface that uses Websql or Indexeddb as available.
  • back to HTML5 and despite not be ready yet (since most browsers do not yet support), Serviceworker in the future will be a fantastic solution to this problem (as can be seen in this video presentation).

As for the Rails server-side implementation, for all the solutions I suggested the server would only have to provide the database data on a JSON page that Javascript could access.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.