581
Chapter 16 Offline web applications
CHAPTER 16 Offline web applications
I
n the preceding chapter, you learned about the most widely used offline solution, web
storage, but it’s not always the best tool for the job. At times, you might need more
advanced features such as true asynchronous support, indexing for faster searching, or
transactions. Those features are available in the other offline storage mechanisms.
This chapter begins by looking at one option that provides all the power of a relational
database, Web SQL. An alternative that’s more of an object database, IndexedDB (Indexed
Database), is covered next; it gives you the power of indexing and transactions without the
need to set up a formal relational structure. Although both those solutions are good for
typical data concerns, neither is designed for storage of files (such as images, text files, XML,
or even movies). For that need, this chapter discusses the FileSystem API. Last, you see how
you can make an entire website offline-friendly with very little effort by using the offline
application HTTP cache.
As each tool is reviewed, pay attention to the levels of support within today’s modern
browsers because this is an important consideration when deciding whether to adopt the
tool for your next application.
Lessons in this chapter:
■■Lesson 1: Working with Web SQL 582
■■Lesson 2: Working with IndexedDB 589
■■Lesson 3: Working with the FileSystem API 600
■■Lesson 4: Working with the offline application HTTP cache 608
Before you begin
To complete this book, you must have some understanding of web development. This chap-
ter requires the hardware and software listed in the “System requirements” section in the
book’s Introduction. Because no current browser supports all offline features, some of the
examples require different browsers if you want to follow along on your own equipment.