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 at 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:
Full list of inserted strings.
Identifiers of deleted strings.
Numbers of start and end cache data version. Resource cache data version corresponds to the number of data source request and is available on viewing cache in the Version string.
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, 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 at the server.
Interaction of mobile device, mobile platform server, and data source on caching:
Mobile device:
Stores one version of cache by parameters.
Generates data get requests to platform server.
Refreshes stored cache on getting delta from mobile platform server.
Mobile platform server:
Stores several versions of cache by parameters for each resource link, credentials, and set of input parameter values.
Receives requests from mobile device.
Checks if the current cache version for requested data is actual.
Refreshes data via a data source request.
Calculated delta between actual cache version and version on a mobile device by cache version number.
Sends delta or full data version to a mobile device.
Data source:
Generates the response corresponding to request parameters, and sends it to mobile platform server.
Data refresh algorithm on a mobile device:
A mobile device sends request to data refresh.
The mobile platform server checks if requested data cache is actual:
If cache is actual, the server calculates delta based on saved data without addressing the data source.
If cache is outdated, the server requests data from the data source and calculates delta.
Delta is sent to a mobile device from the mobile platform server.
The mobile device restores actual version based on the saved data and obtained delta.
Cache use scheme when working with one resource:
To use caching, select the Cache checkbox that is available after resource import. If the checkbox is selected, additional caching parameters are displayed:
Cache Validity. Specify time as: <hours : minutes : seconds>, during which cache is considered actual after it is created. This parameter and cache creation date are used to calculate the time, after which cache is considered outdated. If data is requested from the mobile device until when cache is already considered outdated, the user gets data from the saved cache, otherwise mobile platform server requests data source. To avoid excessive use of memory, set a schedule to delete outdated caches. The box is mandatory.
Saved Strings. Specify the number of strings from 10000 to 100000 written to cache in one iteration.
NOTE. If the number of strings is not specified, speed of cache writing is maximum, although memory use is also maximum.
Stored Old Versions. Specify the number of stored cache versions that ensure processing of requests from mobile devices with different versions of saved data. The number of cache versions if unlimited by default.
NOTE. Stored old versions occupy memory at mobile platform server.
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: