Technology Programming

HTML5 - The New Era of Designing: - Offline HTML5 Web Application

Offline HTML5 web application is a way to allow users to continue interacting with web application while they are not connected to the Internet.In other words It helps to make you connect to the web application while you are not connected to any network. For example, you can access a web application while flying in an airplane, riding in a subway or roaming in the woods.
Another reason to create offline web application is speed. An offline web application must be downloaded only once. After it gets downloaded, all of the files required by the web application are stored on client's computer persistently.Required Resources to develop Offline HTML5 web application:-
1. Manifest file
2. Handler file for serving with a MIME type.1. Manifest File -
A Cache Manifest file always starts with the line of text Cache Manifest. The first line, CACHE MANIFEST, tells the browser that this is a manifest file.
There are three different sections in a manifest file:
CACHE:- A list of explicit URLs to request and store
FALLBACK:- What to do when an offline user attempts to access an uncached file
NETWORK:- Which resources are available only while online

Each section serves a specific purpose.

Example:- In this example the page will be default.aspx. The scripts used in this page will be Scripts/jquery-1.4.4.min.js

CACHE MANIFEST
# Pages name to be downloaded
Default.aspx
# Standard and App Scripts used in above pages
Scripts/jquery-1.4.4.min.js
NETWORK:
# Resources which will only be used when online

Notice that you can add comments to a manifest by starting a line with the hash character (#).

There are two important things that you need to be aware of when using a manifest file. First, all relative URLs listed in a manifest are resolved relative to the manifest file. The URLs listed in the manifest above are all resolved relative to the root of the application because the manifest file is located in the application root.
Second, whenever you make a change to the manifest file, browsers will download all of the files contained in the manifest (all of them). For example, if you add a new file to the manifest then any browser that supports the Offline Cache standard will detect the change in the manifest and download all of the files listed in the manifest automatically.

2. Handler file for serving with a MIME type

The generic handler sends the Manifest.txt file with the MIME type text/cache-manifest.
To do this work there are several ways. You chose depending on your need like for MVC you can write the handler in an ActionResult. You can also do this in a javascript.
Here I am doing this in a separate page called Manifest.ashx
The main two lines of the code.
context.Response.ContentType = "text/cache-manifest";
context.Response.WriteFile(context.Server.MapPath("Manifest.txt"));

The Default.aspx file contains a reference to the manifest. The opening HTML tag in the Default.aspx file looks like this

<html xmlns=€http://www.w3.org/1999/xhtml€ manifest=€Manifest.ashx€>

Notice that the HTML tag contains a manifest attribute that points to the Manifest.ashx generic handler. Internet Explorer simply ignores this attribute. Every other modern browser will download the manifest when the Default.aspx page is requested.

So now you are ready to create an Offline HTML5 web application.
Happy Coding
SHARE
RELATED POSTS on "Technology"
Blitzerwarner: Could You Escape the Speed Cameras?
Blitzerwarner: Could You Escape the Speed Cameras?
What Makes a Perfect Web Design Company?
What Makes a Perfect Web Design Company?
Inside No-Fuss Products In Gaming Computers
Inside No-Fuss Products In Gaming Computers
Gaming Institute, Game Design Schools at PAI-ILS, PAI International Learning Solutions Pune
Gaming Institute, Game Design Schools at PAI-ILS, PAI International Learning Solutions Pune
Free Music Players For Websites
Free Music Players For Websites
'See How NCP Tracks Down Fake Ration Card Holders'
'See How NCP Tracks Down Fake Ration Card Holders'
You Can Stop Panic Attacks in Just two Minutes
You Can Stop Panic Attacks in Just two Minutes
WordPress Blog to WP Site! A Journey to Online Success
WordPress Blog to WP Site! A Journey to Online Success
Videos will give your business portal an extra leverage
Videos will give your business portal an extra leverage
Excellent Ways To Make Weight Loss Work For You
Excellent Ways To Make Weight Loss Work For You
Five Notable Differences between National and International Logo Designs
Five Notable Differences between National and International Logo Designs
Who Should Your Phoenix Web Design Client Be?
Who Should Your Phoenix Web Design Client Be?
White Papers & Other Documents - including ALFLB
White Papers & Other Documents - including ALFLB
Google Analytics Tips
Google Analytics Tips
Want To Make Your Website Faster? Follow These Steps
Want To Make Your Website Faster? Follow These Steps
The Starting of Couture Apparel
The Starting of Couture Apparel
Choose Custom Website Design Services
Choose Custom Website Design Services
Choosing the Right Joomla CMS Developer
Choosing the Right Joomla CMS Developer
A Look at SQL Server Denali AlwaysOn
A Look at SQL Server Denali AlwaysOn
4 Tips to Choose the Perfect Flash Animation Course
4 Tips to Choose the Perfect Flash Animation Course

Leave Your Reply

*