Offline cache

The Totara Mobile application has offline cache enabled for current learning, notifications, and profile features. This enables users to access previously visited (and downloaded) learning while they are offline. The app enables users to download SCORM activities and complete them in offline mode. All offline data is managed by the  Apollo Client.

Configurations

The Apollo Client is configured in the @totara/core/AuthRoutines and has a specific timeout period of 10 seconds for requests. All responses that exceed this timeout period are aborted. The maximum number of request attempts defined is 2.

Setting Timeout
const timeOutLinkWithHttpLink = new ApolloLinkTimeout(10 * 1000).concat(httpLink);

The maximum number of failed request attempts is 2 i.e. it will stop after two failed requests.

Setting attempts
const link = ApolloLink.from([
    errorLink,
    new RetryLink({
      attempts: {
        max: 2,
        retryIf: (error) => {
          if (error.statusCode && error.statusCode === 401) {
            return false;
          } else {
            return !!error;
          }
        }
      }
    }),
    authLink,
    timeOutLinkWithHttpLink
  ]);