Search code examples
azureazure-mobile-servicesofflineapps

Cordova Offline Sync - multiple calls to API on Pull - JS Library


We are observing that there are three API calls happening when we execute an offline sync selective pull query

  1. GET domain/tables/Events?$filter=updatedAt%20ge%20datetimeoffset'1969-12-30T22:00:00.000Z'

  2. GET domain/tables/Events?$filter=updatedAt%20ge%20datetimeoffset'2017-06-27T22:00:00.000Z' (current datetime)

  3. GET domain/tables/Events?$filter=updatedAt%20ge%20datetimeoffset'2017-06-27T22:00:00.000Z'&$skip=1

These 3 calls happen every time a pull is done, can anyone explain why this happens? The selective sync query is created in the following format

syncContext .pull(new WindowsAzure.Query('Events'), 'eventspull') .then(function() { /* pull complete */ });

We are using latest version of the following javascript offline library. https://zumo.blob.core.windows.net/sdk/azure-mobile-apps-client.js


Solution

  • These 3 calls happen every time a pull is done, can anyone explain why this happens?

    This happens because the "pull" function pulls one page from the server table at a time. You can check out the source code here for details.

    Let’s say you have thousands of records. If you execute the query without paging, then it is likely you will tie up your client process on the phone for a considerable period of time as you receive and process the data. To alleviate that and allow your mobile application to remain responsive, the client SDK implements paging. By default, 50 records will be requested for each paged operation. In reality, this means that you will see one more request than you expect.

    For more info, pelease refer to Understanding offline sync.