Generate H5 offline packages

更新时间:
复制 MD 格式

Package your frontend resources into an H5 offline bundle and publish it through the Mobile Delivery Service (MDS) platform to deliver client-side updates without requiring a full app release.

An H5 offline package is a signed archive that bundles HTML, CSS, JavaScript, and image resources for delivery to the H5 container on the client. When the container requests a resource by URL, it first checks the local offline package. If the URL matches a locally bundled resource, the local copy is served; otherwise, the request falls through to the remote server. This interception mechanism is transparent to the WebView — whether content comes from the local bundle or the network makes no difference to the rendering engine.

Generating an offline package has two stages:

  1. Build the frontend .zip package

  2. Generate the .amr package online

Build the frontend .zip package

Two package types are available, each with its own directory structure:

  • Global resource package — shared resources referenced by multiple standard packages (common scripts, fonts, images).

  • Standard resource package — all frontend resources for a single service (HTML, CSS, JS, images).

Note
  • Global resource packages and standard resource packages cannot coexist in the same H5 offline package.

  • The offline package ID (the first-level directory name) must be an 8-digit number.

Global resource package

A global resource package holds common files shared across multiple services — for example, a shared JavaScript library or a common stylesheet. Structure the directory as follows:

  • First-level directory: The 8-digit ID of the global resource package, for example 77777777.

  • Second-level directory: The domain name of the server hosting the resources.

    • Public cloud: Use mcube-prod.mpaascloud.com. Any other domain disables the real-time publishing acceleration feature.

    • Apsara Stack: Use the domain name of the mdsweb server deployed in your Apsara Stack environment.

  • Third-level directory: appId_workspaceId, for example 53E5279071442_test.

  • Directories below the third level: Your custom public resource files. Avoid special characters (any character that the urlencode function encodes) in directory names, file names, and file content.

The resulting resource URL follows this pattern:

  • Public cloud: http://domain-name/appID_workspace/resource-file-path

  • Apsara Stack: http://domain-name/mcube/appID_workspace/resource-file-path

    Important

    In an Apsara Stack environment, insert /mcube after the second-level directory (server domain name) in the resource file path.

    Example:

    In an Apsara Stack environment, the second-level directory is the mdsweb server domain name. If the domain name is mdsweb-outer.alipay.net, the path for common.js shown in the figure below is https://mdsweb-outer.alipay.net/mcube/53E5279071442_test/common.js.

    image.png

Note
  • The absolute path for public resources must not exceed 100 characters. A longer path causes the client to fail loading resources and display a blank page.

  • The server does not manage the version of the global resource package. To version your files, add a subdirectory under the third-level directory.

  • In an Apsara Stack environment, if the server uses HDFS or AFS for file storage, add a directory before the third-level directory whose name matches the bucket name on the mdsweb server.

  • When referencing global resources from a standard offline package, use an absolute path, for example https://mcube-prod.mpaascloud.com/53E5279071442_test/common.js.

image.png

Standard resource package

A standard resource package contains all frontend resources for a single service. Structure the directory as follows:

  • First-level directory: The 8-digit ID of the standard resource package, for example 20171228.

  • Second-level directory and below: Your custom resource files. Store all frontend files under a single subdirectory such as /www, and set the main entry file that the offline package loads by default, for example /www/index.html.

    image.png

Compress the directory into a .zip file

After organizing the directory, compress the entire folder (the one containing the package ID as the first-level directory) into a .zip file.

image.png

Generate the .amr package online

In the console, go to Real-time Release > Offline Package Management. Upload the .zip package from the previous step to the MDS publishing platform to generate the .amr package. For step-by-step instructions, see Create an offline package.

Important
  • When adding a new offline package configuration, set the minimum iOS version in the client scope to a value lower than the Product Version field in the iOS client's info.plist file (see figure below). You can set the minimum iOS client version to 1.0.0.

  • The Product Version and Bundle versions string, short fields in info.plist must have identical values. A mismatch prevents the offline package from taking effect.

image.png