Table of Contents
Preface v
1 A Gentle Introduction to Client-Side Data Storage 1
2 Working with Cookies 3
Cookies? Seriously? 3
Working with Cookies 4
Reading Cookies 5
Deleting Cookies 6
Demos 6
Inspecting Cookies Within Developer Tools 10
Support and Recommended Usage 11
3 Working with Web Storage 13
Web Storage, AKA Local Storage 13
Working with Web Storage 14
Demos 15
Listening for Storage Changes 19
Inspecting Web Storage with Dev Tools 23
Support and Recommended Usage 24
4 Working with IndexedDB 27
Welcome to Deep Data 27
Key IndexedDB Terms 28
Checking for IndexedDB Support 29
Working with Databases 29
Working with Object Stores 31
Making Object Stores 32
Defining Primary Keys 34
Defining Indexes 36
Working with Data 37
Creating Data 38
Reading Data 42
Updating Data 45
Deleting Data 47
Getting All the Data 48
Working with Ranges and Indexes 51
Even More with IndexedDB 54
Storing Arrays 54
Counting Data 59
Inspecting IndexedDB with Dev Tools 59
Support and Recommended Usage 61
5 Working with Web SQL 63
Dead Spec Walking 63
Basic Database Terms 64
Checking for Web SQL Support 64
Working with Databases 64
Working with Transactions 66
Inspecting Web SQL with Dev Tools 72
Support and Recommended Usage 73
6 Making It Easier with libraries 75
"Use the Library, Luke…" 75
Working with Lockr 75
Simplifying IndexedDB with Dexie 80
Working with localForage 88
More Options 90
7 Building a Sample Application 91
Let's Build Something! 91
Our Sample Data 92
The Application 95
The Code 97
Wrap-up 103
Index 105