Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8512435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:16:48+00:00 2026-06-11T04:16:48+00:00

I am planning to use a localStorage adapter for backbone.us to allow it to

  • 0

I am planning to use a localStorage adapter for backbone.us to allow it to sync/fetch to local storage instead of via jqXHR. This is so that my app can work offline.

However, once my app is back online, I’d make an ajax call to sync up the local dataset with the server, or alternatively build in some sort of a “replay” system to send only the changes over.

However, how would I handle when the data set has diverged (changed on both server and client)? Which source has the correct data set?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T04:16:50+00:00Added an answer on June 11, 2026 at 4:16 am

    You should be able to create a simple two-way synchronization protocol by doing the following:

    1. On all tables that should be synchronized, have a “last updated” timestamp field which is updated whenever you modify a row (including inserts and deletes, see further down).

    2. For “id”, avoid auto-incrementing integers (which would require talking to the server to figure out the next value), and use GUIDs instead. The localStorage adapter does this by default. Using a GUID, both the server and client can generate new rows without talking to eachother.

    3. You need to use “soft deletes”. Instead of actually deleting a row, have a flag that you mark as deleted and filter on this flag whenever you need to list your collection of objects. That way, even deletes gets propagated properly. You can do “housekeeping” (actually deleting the rows) for all rows that have remained deleted for a certain amount of time, where that time needs to be larger than the largest possible “offline” time to make sure deletes have propagated.

    4. Store a local timestamp of the last time you sync’ed with the server on your client. Making sure you store timestamps on both the server and client with the proper timezones is important.

    5. When you sync against the server from the client, send it your “last sync” timestamp, and the server should send you everything that changed since that time. With the new timestamp provided by the server, store that as your new “last sync time” locally on the client. Updated/insert received whatever rows you get depending on the GUID (update if you have them locally, insert if not).

    6. If you have locally stored changes, send all locally modified rows since the original timestamp from your client to the server, preferrably before reading updates from the server (you can also do it after, but regardless, you should probably check the updated timestamp to figure out which update is more recent and handle it according to whatever conflict resolution policy you select, or none if it’s not important).

    7. Feel the pain when you realize that for practical cross platform localstorage usage, you are currently limited to about 2.5 megabytes of data. That will hopefully change soon. And before you decide to go IndexedDB instead to work around the limitations, the APIs haven’ stabilized yet, and most implementations are half-assed and incompatible.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm planning to use cloud storage in my WP7 app. Can I use Skydrive
i'm planning to use a .swf file as a header. this won't work. <img
We're planning to use the Spring 3.1 cache abstraction instead of the Grails Spring
I am planning to use the sync framework to sync data between sql server
I am planning to use sockets (local TCP) to communicate between two processes (running
I am planning to use Facebook registration to allow people to use their Facebook
I am planning to use jquery in Rails instead of prototype. I am not
I am planning to use various objects that are exposed as COM objects. To
Am planning to use cookies to communicate between two browser windows. Am wondering if
We are planning to use Team Foundation Server, but we need to decide whether

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.