Application cache management in Desktop Browser and Mobile Web apps
MobileFirst Studio provides mechanisms by which we can control the contents of the application cache for Desktop Browser and Mobile Web environments.
The application cache
Ideally, you want mobile and desktop web applications to be able to work when the user is offline. Older browsers had their own caching mechanisms, but they were not always reliable. The release of HTML5 addressed this need with the introduction of the application cache, which provides users three advantages:
- Offline browsing – users can work with the application when they are offline.
- Speed – cached resources are local, and thus load faster.
- Reduced server load – the browser only downloads resources that are updated or changed from the server.
The application cache manifest
The Cache Manifest is a simple text file that lists the resources that the browser is to cache for offline access. It contains a list of resources explicitly cached after the first time they are downloaded. The Cache Manifest can contain three sections:
- CACHE – Files and resources listed under this heading (or immediately after the CACHE MANIFEST heading if no sections are present) will be explicitly cached after the first time they are downloaded.
- NETWORK – Files listed under this heading are white-listed resources that require a connection to the server. All requests to these resources bypass the cache, even if the user is offline.
- FALLBACK – An optional section that specifies fallback pages if a resource is inaccessible. The first URI listed is the primary resource, and the second URI is the fallback. Both URIs must be relative and from the same origin as the manifest file.
When the browser opens a document that includes the manifest attribute, the browser loads the document and then fetches all the entries listed in the Cache Manifest file. If no application cache exists, the browser creates the first version of the application cache.
If unnecessary or redundant files are included, they must all be fetched before the application can start, which can create a poor user experience. The procedure that follows documents ways in which we can edit the Cache Manifest to reduce the start time for the Desktop Browser and Mobile Web applications.
- 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.
Parent topic: Optimizing MobileFirst applications