Creating a cache manifest for offline use
Creating a cache manifest for offline use
To enable users to continue interacting with mobile apps and documents even when their network connection is unavailable, you can provide a cache manifest that lists the files needed for the mobile app to work offline. The cache manifest is a simple text file defined using an HTML rule form named pyCustomAppCache. Each line in the cache manifest refers to a single static resource such as an HTML file, an image file, a CSS file, a font file, or a JS file.
Resources listed in the cache manifest constitute all static resources needed by a mobile app to run offline. You can use the app while a device is offline if the device has the resource cache.
To define the cache manifest, save a copy of the pyCustomAppCache record to your application ruleset.
Working from a clean mobile app, run the app through an HTTP proxy. Work through all the screens that are displayed and look for any HTTP requests.
Add requested resources to the cache manifest so that if the user only logs in and goes to the portal page but then goes offline, all static resources are correctly cached.
Cache manifest syntax
To add a resource file to the cache manifest record, add each resource file on a separate line.
If the name of the requested resource file uses a series of numbers in the src attribute such as webwb/filename_1234567890.xxx!!.xxx
, use the <pega:binaryfile> element with the name and app attributes.
If the name of the requested resource file includes capital letters, use the keepCase attribute with a value of true. The keepCase attribute ensures that a case-sensitive name is read correctly. Otherwise, the name is assumed to be lowercase.
For example, upon inspecting the HTTP request in the Document Object Model (DOM), the requested resource is displayed, in part, as <img src="https://demo5-academy.pega.com/webwb/Custom-Logo_1662150348.svg%21%21.svg">. Add the resource file to the cache manifest using the <pega:binaryfile> element with the name, app, and keepCase attributes:
<pega:binaryfile name="Custom-Logo.svg" app="webwb" keepCase="true" />.
If the name of the requested resource file is prefaced with an additional directory, preface the <pega:binaryfile> element in the cache manifest with the name of the additional directory.
For example, upon inspecting the HTTP request in the DOM, the requested resource is displayed, in part, as <img src="https://demo5-academy.pega.com/webwb/webwb/Custom-Logo.svg">. Add the resource file to the cache manifest using the <pega:binaryfile> element prefaced with webwb/:
webwb/<pega:binaryfile name="Custom-Logo.svg" app="webwb" keepCase="true" />.
If the name of the requested resource file is the name of the resource file, enter the path and name of the file as displayed in the DOM. For example, upon inspecting the HTTP request in the DOM, the requested resource is displayed, in part, as <img src="https://demo5-academy.pega.com/webwb/Custom-Logo.svg">. Add the resource file to the cache manifest using:
webwb/Custom-Logo.svg.