What is application cache in HTML5?( ASP.NET HTML 5 interview questions with answers)
- By Shiv Prasad Koirala in ASP.NET
- Dec 14th, 2013
- 7233
- 0
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 :-
CACHE MANIFEST
# version 1.0
CACHE :
Login.aspx
- 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#.
Response.ContentType = "text/cache-manifest";
Response.Write("CACHE MANIFEST \n");
Response.Write("# 2012-02-21 v1.0.0 \n");
Response.Write("CACHE : \n");
Response.Write("Login.aspx \n");
Response.Flush();
Response.End();
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.
manifest="cache.aspx">
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.
CACHE MANIFEST
# version 2.0(new)
CACHE :
Login.aspx
In case you are going for ASP.NET interview please do see the below interview revision video provided by www.questpond.com
Shiv Prasad Koirala
Visit us @ www.questpond.com or call us at 022-66752917... read more