Caching tunneled URL responses

Apps that access enterprise servers can use AppTunnel with HTTP/S tunneling, as described in AppTunnel. By default, for a tunneled URL request:

  • The data for the URL is reloaded from the originating source. Any existing locally cached response is ignored.

  • The data in the response is not stored in the local cache.

The reason that AppTunnel with HTTP/S tunneling does not use locally cached responses is to avoid caching sensitive enterprise server data on the device.

However, some apps have requirements to use locally cached responses. Some examples are:

  • The app requires a response even when the device has no network connectivity.

  • The app requires a customized response.

If your app requires locally cached responses for URL requests that use AppTunnel with HTTP/S tunneling, use the following AppConnect Cordova Plugin method:

AppConnectCordova.allowLocalCachingForTunneledRequests(flag)

The value of flag has the following impact:

  • true

Allows caching for requests and responses that use AppTunnel with HTTP/S tunneling. However, whether caching actually occurs depends on the cache policy for the URL request.

  • false

Clears all cached responses, including responses for URL requests not using AppTunnel with HTTP/S tunneling.

IMPORTANT:

  • Wait for the AppConnectCordova event 'appconnect.isReady' before calling AppConnectCordova.allowLocalCachingForTunneledRequests().

  • Do not cache sensitive data.