logo

RapidWebView

Getting Started
Github

Overview

Understanding the architecture

RapidWebView SDK uses two caching concepts from The offline cookbook:

caching strategies

RapidWebView SDK is a combination of 3 components: The asset downloader, The request interceptor and The Javascript Interface.

Asset Downloader

The asset downloader is responsible for caching specified static asset files which belong to the web-apps that you would load in your web view. The list of asset files to be cached on app launch are mentioned in the asset-manifest file (you can read the details about the asset-manifest here).

Upon initialisation, the asset downloader uses retrofit to fetch the remote asset-manifest. It reads the version and matches it against the local cache version. If the remote version and the local versions match, the asset downloader finishes it's process. If the remote version and local versions are different, the asset downloader starts a background task which clears the local cache and starts downloading individual asset files mentioned in the asset-manifest. Once all asset files are downloaded, the asset downloader updates the local cache version and saves it on the local disk.

We recommend that you execute asset downloader on each app launch so that the cached assets are always updated to the latest version.

Request Interceptor

Request Interceptor is a Client class which inherits android.webkit.WebViewClient and overrides shouldInterceptRequest. It intercepts each fetch request made by the webview while loading the web-app and returns asset data from the local cache disk if it matches the requested resource. If a local cache copy is found, the request will be fulfilled by the network.

By servicing assets locally, web-app load times are reduced significantly.

Javascript Interface

This is an add-on module included in the RapidWebView-SDK. It's a collection of commonly used interface functions which can be used by your web-app (loaded via webview) to interact with the native functions of Android (e.g., vibration, notification). You can find more details here.

logo

RapidWebView

Made in 🇮🇳 by WorkIndia .