如何在indexedDB和MySQL之间同步数据

I want to synchronise data between the indexedDB(JsStore) and MySQL so that users can have access to their data and some basic functionalities. There should not be data duplication and both should

So when user is offline, data is saved to indexeddb and when user is online the data needs to be send back to server and if something is added in server while user was offline then it should get the new data from server too. So basically data needs to be sync between server and client.

My Question is how can I achieve this & what will be the best approach ?

Information : I am using

Backend : PHP and MySQL

FrontEnd : Javascript , JQuery , Bootstrap