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.
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 :-
# version 1.0
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");
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.