HTML5 brought the application, a new feature that allows to make web applications and sites available offline cache. The new standard also provides a simple way to preload some or all of your web application assets (HTML files, images, CSS, JavaScript and so on) while the client is always online. In this process of caching files are stored in a cache for the application, where they sit ready for further offline use.
Compare this to regular browser, in which the pages that you visit are cached in the cache of the browser based on the rules of server and configuring client-side caching. But even if web pages are cached normally, it does not provide a reliable way to allow you to access the pages while you are offline (by plane, for example). In addition, an application cache can cache pages that have not been visited and are generally not available in the regular browser cache. Preloading files can even speed up the performance of your site, if you use course bandwidth to download these files at the outset.
Regularly caching can lead to undesirable results while you're offline.
The mechanism that makes available web applications offline is simple: create a manifest file lists the assets of your application and the reference in an attribute manifest in html elements (text) of your web pages. Simple sounds? This is the case. Don't forget that there are some common misconceptions about how offline web apps work and any caching of the browser are now for you, you can get a few surprises (tricky) when you try to debug and test your web applications (online and offline). This article explains what it takes to fend for themselves, so you don't have to learn the hard way. This article also covers some lower-level object and event features that you can tap application cache. Sounds good? Say great start!
Note: a startup files that comprise a web application offline sample set is available at: http://tech.kaazing.com/training/offline/peter-lubbers-html5-offline-web-apps-presentation-code.zip
Fundamental principles
Let's start with the basics. Consider a web application that has a few web pages: a page index, a CSS file, images and JavaScript files. This web site may be made available offline in less than five minutes (once you get it blocking). Here's how:
Add the following directive in the first line:
CACHE MANIFEST
List the files that you want to make available offline (one row per file), as shown in the following example:
CACHE MANIFEST
index.html
cache.html
Resources/IMG/HTML5.PNG
Resources/CSS/html5.css
Resources/js/HTML5.js
Note: files must be referenced in the manifest file. Full URL is allowed as well.
Configure your server to be used with the correct mime type .manifest files (this is covered more in detail later) will to index your site. The page load, and to store the files locally, most browsers will ask if you want to make the files available for use in offline mode. The browser will then be analyzed the manifest file and download all of the assets specified in the file. Note: Unlike implementing caching regular browser, you haven't actually visit each page to load in the cache.Go application offline and continue to browse and enjoy your site.
Notification of storage offline browser
Peter Lubbers is documentation and training Kaazing Director where he oversees all aspects of documentation and training. He is co-author of the book Apress Pro HTML5 programming and taught HTML5 training courses. A follower of the HTML5 and WebSocket, Peter often speaks at international events.
Prior to joining Kaazing, Peter worked as an architect information at Oracle, where he wrote many books. It also develops solutions for automation documentation and two of his inventions are patented.
Originally from the Netherlands, Peter served a special forces commando in the Royal Dutch Green Berets. In his time free (ha!) Peter likes to run ultra-marathons. He is the 2007 and 2009 ultrarunner.net Series champion and three times winner of the Tahoe Super Triple marathon. Peter lives in the Tahoe national forest and likes to operate in the foothills of the Sierra Nevada of Lake Tahoe (preferably in only once!).
No comments:
Post a Comment