HTML5 APPLICATIONS DEVELOPMENT MANUAL

(lu) #1

In HTML5, developers can use the Web storage instead, which offers


more flexibility, larger data sets, and better performance. The localStorage


method allows users to save larger amounts of data from session to s ession


(persistent data), and there’s no time limit as to how long the data exists.


The SessionStorage method keeps data only for one session (until the


browser is closed), which is also referred to as “per-tab storage.” Using these


methods, specific data is transferred only when requested, so it’s possible to


store a relatively large amount of data without slowing down the connection


or site.


Appcache for offline files


Another way to use Web storage is to store data locally when a user is


offline. The Application Cache, or AppCache, stores resources like images,


HTML pages, CSS files, and JavaScript - data that would ordinarily be stored


on a server. Because the resources are stored on the client’s hard disk or


device, the resources load faster when requested.


Using AppCache, a developer uses a text file called a “cache


manifest” to specify the files a Web browser should cache offline. Even if a


user presses the Refresh button offline, the app will load and work correctly.

Free download pdf