What is application cache in HTML5?( ASP.NET HTML 5 interview questions with answers)
One of the most demanded things by end user is offline browsing. In other words if internet connection is not available page should come from browser cache i.e. offline and application cache helps you to achieve the same.
Application cache helps you to specify which files should be cached and not cached.
So how do we implement application
cache in HTML 5 ?
The first thing in we need to specify is the "manifest" file. "manifest" file helps you to define how your caching should work. Below is the structure of the manifest file :-
- All manifest file starts with CACHE MANIFEST statement.
- #( hash tag) helps to provide the version of the cache file.
- CACHE command specifies which files needs to be cached.
- The content type of the manifest file should be "text/cache-manifest".
Below is how cache manifest has been provided using ASP.NET C#.
One the cache manifest file is created the next thing is to provide the link of the manifest file in the HTML page as shown below.
When the above file runs first time it gets added in the browser application cache and in case server goes down the page is served from the application cache.
So how do we refresh the application
cache of the browser?
Application cache is removed by changing version number to a new version number as specified in the "#" tag in the below code.
In case you are going for ASP.NET interview please do see the below interview revision video provided by www.questpond.com