HTML5 application cache manifest and it’s types

HTML5 application cache manifest and its types

Basics of html cache manifest

For caching the web page, it is mandatory to declare the manifest with html element on every and each page. A particular webpage can’t be cached until we don’t declare the manifest file.

The recommend file extension for a manifest file is appcache. The manifest file also needs to configure with the correct MIME-type, which must be configured well on the web server. The format may has follows: text/cache-manifest.

What is HTML5 Manifest?

It’s a simple text file, which tells the browser for particular cache processing. In details we can say it sends a command to browser for specific file type to be stored in the cache.

We can also send a denying command, if we have to tell the browser that a specific file shouldn’t be store in the cache
Html 5 manifest types

The Manifest file has been defined in three particular types. You can also say a Manifest file can contain three sections in it. Here are the details of three sections or types:

       Cache Manifest
       Network
       Fallback

Cache Manifest

The files listed under this category only will be cached after they are downloaded for first time. To declare the cache manifest type, you need to write CACHE MANIFEST at the first line of the page.
Cache Manifest: Syntax

CACHE MANIFEST
/theme.css
/logo.gif
/main.js

In the above demonstrated syntax, there are three types of file have been declared: CSS file, GIF file and JS file. When the user will use the internet connection for the first time, these three files will be download. And once the download is finished, the user can access these files, even when no internet connections.

html5 application cache manifest


Network

The files listed under this category will always require an internet connection. Without the internet connection these files will not be served.

Often we have seen that we include some PHP files or other resources to get access in the database. To do this such event, we authorize the user with login system. In the section of Manifest type, we can prevent the user for accessing the particular file as cached version.

Network: Syntax
NETWORK:
login.php

Instead of declaring a specific file, we can also use an asterisk sign to prevent all resources to be cached. And user must have an internet connection to get access.

Fallback

This section of Manifest can be used if we want to serve a specific file in case of no internet connection. In this process we create a specific file and set it in the fallback. Once the user is offline or not able to access the internet connection. The specified file will be served.

Fallback: Syntax
FALLBACK:
/html/ /offline_backup.html

 Conclusion

This seems good if someone has issue with internet connection, but be careful what you cache. Once the browser cache the file, the user will continue seeing the cached version until you don’t change your updates with program or the user doesn’t clear the cache of the browser.

Leave a Reply

Your email address will not be published. Required fields are marked *

x