Game Development Reference
In-Depth Information
sent to the server every time because of the way they work. The year 2009 saw the appearance of the
Web Storage standard, often referred to as DOM Storage.
Web Storage provides a convenient way to store up to 5 megabytes per domain in Firefox, Chrome, and
Opera, and up to 10 megabytes in IE. Importantly, the standard has complete browser support, as shown
in Table 10-5.
Table 10-5. Web Storage: Method of storing data locally (like cookies)
IE
Firefox
Safari
Chrome
Opera
Two versions back
7.0
5.0
4.0
12.0
11.0
Previous version
8.0
6.0
5.0
13.0
11.1
Current
7.0
5.1
14.0
11.5
9.0
Near future
8.0
15.0
12.0
6.0
Farther future
10.0
9.0
16.0
12.1
We have two storage locations available: localStorage and sessionStorage . Quite obviously, the former
stores data for the entire web site, while the latter keeps the data during the session only. Let us look at
Listing 10-12, an example of using sessionStorage .
Listing 10-12. Example of sessionStorage use
// Setting temporary value to sessionStorage
sessionStorage.setItem(yourkey, yourvalue);
// Getting value
var item = sessionStorage.getItem(yourkey);
// Removing key
sessionStorage.removeItem(yourkey);
// Clearing session cache
sessionStorage.clear();
It is all very simple and seemingly requires no improvement, but data is stored in the key-value format,
and many considered this insufficient in the modern world of relational databases.
This gave rise to new standards: Web SQL Database implemented in Chrome, Opera, and Safari, and
Indexed Database promoted by Mozilla in Firefox. The two standards co-existed for some time, but in late
2010, work on Web SQL was stopped in favor of Indexed DB. Seeing how the latter is only implemented in
Firefox 4 or newer and Chrome 11 and newer, and that the future of Web SQL implementation in other
browsers is unclear, it is worth taking a very careful approach to the selection of a back-end for the client
database.
 
Search WWH ::




Custom Search