top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

Simple way to implement application cache in HTML 5?

+2 votes
87 views
Simple way to implement application cache in HTML 5?
posted May 9, 2014 by Kapil Kapoor

Share this question
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button

1 Answer

0 votes

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 :-

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.

<html 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.

answer May 13, 2014 by Upma
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...