Caching

Caching is used to speed up loading of requested data to a user's mobile device. Cache is a copy of data obtained from data source resource saved on a mobile platform server. When data is requested from a mobile device the server returns update from the saved cache without addressing to data source. This reduces time for request processing.

TIP. If the amount of requested data is small, use transfer of transaction data to process response on lost connection.

Cache stores data source responses with specifying versions, cache saving date, cache validity expiration time, information for comparing request with cache: target resource, credentials used on data source request, and input request parameters. Resource cache is available to control caches by parameters in the Cache Control subsection.

Delta is a difference between two versions of resource data that enables a mobile device to restore new resource version from the stored old version.

Delta contains the following for each resource table:

For details about delta use in requests, see the Designating Delta Versions in Requests section.

Apart from version number, resource cache contains the ETag unique identifier sent together with data or delta. If the unique identifier is specified in the request, a mobile platform server automatically determines cache version, to which request corresponds; it calculates and sends delta to a mobile device between the request and the latest cache version on the server.

Updating Data on Caching

Interaction between a mobile device, a mobile platform server, and a data source on caching:

Data refresh algorithm on a mobile device:

  1. A mobile device sends request to data refresh.

  2. A mobile platform server checks if requested data cache is actual:

  1. Delta is sent to a mobile device from a mobile platform server.

  2. A mobile device restores actual version based on the saved data and obtained delta.

Cache use scheme when working with one resource:

Data Integrity Check

Data integrity check is executed for cached resources:

  1. When data is obtained from a data source, the hash sum is calculated on a mobile platform server by requested resource record identifiers.

  2. The hash sum calculated on a mobile platform server is sent to a mobile device together with the actual cache version or the delta between the last two cache versions.

  3. Resource data is updated on the mobile device, after which the hash sum is calculated on the mobile device.

  4. The hash sum obtained from a mobile platform server is compared with the hash sum calculated on a mobile device:

Setting Up Caching Parameters

To use caching, select the Cache checkbox that is available after resource import. If the checkbox is selected, additional caching parameters are displayed:

Set caching parameters:

NOTE. If the number of strings is not specified, speed of cache writing is maximum, although memory use is also maximum.

NOTE. Stored old versions occupy memory on a mobile platform server.

NOTE. When this parameter is used, take into account the following:
   ● cache size should not exceed 512 Mb.
   ● Storing last cache version results in the increased RAM usage.

NOTE. When this parameter is used, take into account the following:
   ● Number of deltas in RAM should be less or equal to the number of older cache versions specified in the Older Versions to Store parameter.
   ● Storing the specified number of deltas results in the increased RAM usage.

Change resource input parameters to get a data slice via requests, and click the Save button. The resource is added to the list of data source resources, and its input parameters are available to control resource cache.

Requests to data source resources are given in the Method for Working with Table Resources section.

See also:

Import of Data Source Resources | Resource Parameters