Posts in current category
May 03, 2021 13:10 HTML5
With HTML5, you can easily create an offline version of your web app by creating a cache file. This means that you can access it without a network connection.
HTML5 introduces application caching, which means that web apps can be cached and accessible when there is no Internet connection.
Application caching brings three benefits to your app:
Internet Explorer 10, Firefox, Chrome, Safari and Opera support app caching.
The following example shows an HTML document with cache manifest (for offline browsing):
To enable application caching, include the manifest property in the document's label:
Each page that specifies manifest is cached when the user accesses it. If the manifest property is not specified, the page is not cached (unless the page is specified directly in the manifest file).
The recommended file extension for the manifest file is :.appcache.
Note that the manifest file needs to be configured correctly for MIME-type, which is "text/cache-manifest". It must be configured on a web server.
A manifest file is a simple text file that tells the browser what is cached (and what is not cached).
The manifest file can be divided into three parts:
The first line, MANIFEST, is required:
The following NETWORK section states that the file "login .php" is never cached and is not available when offline:
You can use an asterisk to indicate that all other resources/files require an Internet connection:
The following FALLBACK section provides that if an Internet connection cannot be established, replace all files in the /html5/directory with "offline .html" instead:
Note: The first URI is a resource and the second is a substitute.
Once the app is cached, it remains cached until:
Please pay attention to the cached content.
Once the files are cached, the browser continues to display the cached version, even if you modify the files on the server. To ensure that the browser updates the cache, you need to update the manifest file.
Note: Browser capacity limits on cached data may not be the same (some browsers set limits of 5MB per site).