You are here: Home ‣ Dive Into HTML5 ‣
LET’S TAKE THIS OFFLINE
Show table of contents
Hat is an offline web application? At first glance, it sounds like a contradiction in terms. Web pages are things you download and render. Downloading implies a network connection. How can you download when you’re offline? Of course, you can’t. But you can download when you’re online. And that’s how HTML5 offline applications work.
From there, most of the work is up to you, the web developer. There’s a flag in the DOM that will tell you whether you’re online or offline. There are events that fire when your offline status changes (one minute you’re offline and the next minute you’re online, or vice-versa). But that’s pretty much it. If your application creates data or saves state, it’s up to you to store that data locally while you’re offline and synchronize it with the remote server once you’re back online. In other words, HTML5 can take your web application offline. What you do once you’re there is up to you.
IE FIREFOX SAFARI CHROME OPERA IPHONE ANDROID
· 3.5+ 4.0+ 5.0+ 10.6+ 2.1+ 2.0+
THE CACHE MANIFEST
web application revolves around a cache manifest file. What’s a manifest file? It’s a list of all of the resources that your web application might need to access while it’s disconnected from the network. In order to bootstrap the process of downloading and caching these resources, you need to point to the manifest file, using a manifest attribute on your element.
Your cache manifest file can be located anywhere on your web server, but it must be served with the content type text/cache-manifest. If you are running an Apache-based web server, you can probably just put an AddType directive in the. htaccess file at the root of your web directory:
AddType text/cache-manifest. manifest
Then make sure that the name of your cache manifest file ends with. manifest. If you use a different web server or a different configuration of Apache, consult your server’s documentation on controlling the Content-Type header.
ASK PROFESSOR MARKUP
☞Q: My web application spans more than one page. Do I need a manifest attribute in each page, or can I just put it in the home page?
A: Every page of your web application needs a manifest attribute that points to the cache manifest for the entire application.
OK, so every one of your HTML pages points to your cache manifest file, and your cache manifest file is being served with the proper Content-Type header. But what goes in the manifest file? This is where things get interesting.
The first line of every cache manifest file is this:
After that, all manifest files are divided into three parts: the “explicit” section, the “fallback” section, and the “online whitelist” section.