Configuring Caching

Configuring Caching

You can enable or disable caching as well as specify configuration settings when initializing a new Everlive object. You can also manage caching for each separate content type or request.

By default, caching is disabled.

This article is organized as follows:

Enable Using Default Settings

To enable caching with default settings, initialize the Everlive instance as follows:

el = new Everlive({
    appId: 'your-app-id',
    caching: true
)}

Change Default Values

You can supply various settings to the Everlive instance such as storage options, cache age, and setting for separate content types:

var el = new Everlive({
    appId: 'your-app-id',
    caching: {
        maxAge: 120, //Global setting for maximum age of cached items in minutes. Default: 60.
        enabled: true, //Global setting for enabling/disabling cache. Default is FALSE.
        typeSettings: { //Specify content type-specific settings that override the global settings.
            "Countries": {
                maxAge: 43200

            },
            "MyType2": {
                enabled: false
            }

        }
    }
});

Per-Operation Settings

Methods are available that allow you to specify whether the result of a specific request must be cached or not. These override the global and per-content-type caching settings.

Read Up-to-Date Data

Use the ignoreCache method to skip the cache and always read fresh data from Telerik Platform. Note that the result of the operation is still cached.

el.data("Books").ignoreCache().get(filter).then();

Force Cache Use

Use the forceCache method to always read data from the cache regardless of the maxAge value. In case the request is not cached, the SDK silently proceeds to contact the server and get the latest data.

el.data("Books").forceCache().get(filter).then();

Override Cached Data's Maximum Age

Use the maxAge method to set a new maximum age just for the current request. The new value overrides both the global setting and the content type setting (if set).

el.data("Books").maxAge(maxAge).get(filter).then();

See Also

Start a free trial Request a demo
Contact us: +1-888-365-2779
sales@telerik.com
Copyright © 2016-2017, Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.