Manage the application Cache Manifest in MobileFirst Studio
The procedures for managing and editing the contents of the application cache for Desktop Browser and Mobile Web applications are listed in this section.
With IBM MobileFirst Platform Foundation, we can control the Cache Manifest in web environments (Desktop Browser and Mobile Web). The name of the Cache Manifest file is worklight.manifest. This file is located in the folder for each of these types of environments.
We can now view (and edit) the contents of this file in MobileFirst Studio, as shown in the following screen capture:
A new attribute now exists in the Application Descriptor (application-descriptor.xml) for Desktop Browser and Mobile Web elements. The current setting of this attribute, called <cacheManifest>, can be are viewed, as shown in the following screen capture:
For more information about Application Descriptor attributes, see The application descriptor.
The <cacheManifest> attribute accepts three values, as shown in the following table. No matter which value or mode is selected, if the Cache Manifest does not exist, the MobileFirst Studio builder generates the default Cache Manifest to give you something to start with. But after creating this file, the builder leaves the resulting Cache Manifest file in its default no-use mode unless you explicitly change the setting.
Property Description generated In this mode, the MobileFirst Studio builder generates a default Cache Manifest and includes it in the application's HTML files. The default Cache Manifest is generated depending on the environment:
- For Desktop Browser environments – all resources are under NETWORK, which means: no cache at all.
- For Mobile Web environments – all resources are under CACHE, which means: cache everything.
In generated mode, in addition to creating the Cache Manifest, the builder creates a backup of the previous Cache Manifest, called worklight.manifest.bak. This file is overwritten in every build.
no-use In this mode (which is the default), the Cache Manifest is not included in the application's HTML files. This setting means that there is no Cache Manifest and that decisions about which resources are cached are up to the browser. user In this mode, the MobileFirst Studio builder does not generate the Cache Manifest, but it does include it in the application's HTML files. This setting means that the user must maintain the Cache Manifest manually.
Edit the Cache Manifest
If we select the Application Descriptor (application-descriptor.xml file) in Design view, we can view and set the current mode of the <cacheManifest> attribute:
In this view, each of these attribute options is given a description:
- Not Included in the application (default) corresponds to no-use mode
- Managed by MobileFirst corresponds to generated mode
- Managed by user corresponds to user mode
The only <cacheManifest> mode that enables the user to edit the Cache Manifest is user. If we attempt to edit the file in any other mode, MobileFirst Studio displays the following message:
If we click Yes on this window, we can change the <cacheManifest> mode interactively and then continue to edit the file. We can also change the <cacheManifest> mode at any time with MobileFirst Studio DDE editor.
The default <cacheManifest> setting for new MobileFirst projects is Not Included in the application (no-use mode).
If wer testing reveals that certain resources can be removed from the generated Cache Manifest, we can change the setting to Managed by user (user mode). Then, we can edit the Cache Manifest and conduct more performance tests before you deploy to the production environment.
For example, you might notice that the Cache Manifest contains large images or other resources not used by the web application but need to remain in the development environment for other platforms. If we edit the Cache Manifest, we can remove them so the web versions of this app load more quickly.
An example of a generated Cache Manifest file for a Desktop Browser environment is shown in the following sample:
CACHE MANIFEST # Created: 2013-05-13 16:55:34 UTC # Modifying this file is possible only when the Cache Manifest value in # the application descriptor is set to "Managed by user" common/js/base.js common/js/busy.js common/js/sjcl.min.js common/js/wl_.min.js common/js/wlcommon.js common/js/wljq.js css/tptp.css images/icon.png images/icon114x114.png images/icon57x57.png images/icon72x72.png images/thumbnail.png js/initOptions.js js/messages.js js/tptp.js tptp.html wlclient/css/wlclient.css wlclient/images/empty.gif wlclient/js/analytics/Tealeaf.min.js wlclient/js/analytics/analytics.js wlclient/js/challengeHandlers/antiXSRFChallengeHandler.js wlclient/js/challengeHandlers/authenticityChallengeHandler.js wlclient/js/challengeHandlers/deviceAuthAutoProvisioningChallengeHandler.js wlclient/js/challengeHandlers/deviceAuthNoProvisioningChallengeHandler.js wlclient/js/challengeHandlers/remoteDisableChallengeHandler.js wlclient/js/deviceAuthentication.js wlclient/js/deviceSensors/acquisition.js wlclient/js/deviceSensors/bind.js wlclient/js/deviceSensors/geo.js wlclient/js/deviceSensors/geoUtilities.js wlclient/js/deviceSensors/triggers.js wlclient/js/deviceSensors/wifi.js wlclient/js/diagnosticDialog.js wlclient/js/encryptedcache/encryptedcache.js wlclient/js/encryptedcache/externs.js wlclient/js/events/eventTransmitter.js wlclient/js/features_stubs/jsonstore_stub.js wlclient/js/messages.js wlclient/js/window.js wlclient/js/wlclient.js wlclient/js/wlfragments.js wlclient/js/worklight.js NETWORK: *
Parent topic: Application cache management in Desktop Browser and Mobile Web apps