Observe offline package behavior at the HTTP level (4): fallback

更新时间:
复制 MD 格式

When the H5 container cannot load offline package resources locally, it falls back to fetching them from an online CDN.

If the H5 container cannot obtain required resources locally, for example, because local signature verification of an offline package fails, the client falls back to fetching resources from online addresses. The basic process is as follows:

  1. The client sends a request to the MDS server with IDs and local version numbers of all H5 apps that have been locally installed.

  2. If the offline package exists, the server returns related information.

  3. The client takes the initiative to download the amr file of the offline package based on the Package URL and Download configuration parameters in the returned information.

  4. If the H5 container fails to locally obtain the offline package resources for some reason, the client needs to use the fallback base URL in the returned information. The container can use this URL to visit the online CDN for loading the H5 application resources, such as HTML, Javascript, and CSS files, but not amr files.

Procedures

  1. The client obtained the offline package information and downloaded the amr file.

    The amr file is downloaded

  2. The client downloads H5 application resources from the fallback address.

    Download H5 application resources

Note

Example of fallback mode log: 3-offline-package-fallback-example.chls.zip