This eBook includes the following formats, accessible from your Account page after purchase:
EPUB The open industry format known for its reflowable content and usability on supported mobile devices.
PDF The popular standard, used most often with the free Acrobat® Reader® software.
This eBook requires no passwords or activation to read. We customize your eBook by discreetly watermarking it with your name, making it uniquely yours.
Also available in other formats.
Register your product to gain access to bonus material or receive a coupon.
Use Service Workers to Turbocharge Your Web Apps
“You have made an excellent decision in picking up this book. If I was just starting on my learning path to mastery of Progressive Web Apps, there are not many folks I would trust more to get me there than John.”Software developers have two options for the apps they build: native apps targeting a specific device or web apps that run on any device. Building native apps is challenging, especially when your app targets multiple system types—i.e., desktop computers, smartphones, televisions—because user experience varies dramatically across devices.
—Simon MacDonald, Developer Advocate, Adobe
Download the sample pages (includes Chapter 3)
Foreword xi
Preface xii
Acknowledgments xv
About the Author xvi
Chapter 1: Introducing Progressive Web Apps 1
First, a Little Bit of History 2
PWAs Are . . . 2
Making a Progressive Web App 4
PWA Market Impact 6
PWAs and App Stores 7
Wrap-Up 7
Chapter 2: Web App Manifest Files 9
Save to Home Screen 11
Making a Web App Installable 16
Anatomy of a Web App Manifest 17
Controlling the Installation Experience 26
Preparing to Code 27
App Installation in Action 29
Troubleshooting 41
Manifest Generation and More 42
Wrap-Up 42
Chapter 3: Service Workers 43
PWA News 43
Introducing Service Workers 44
Preparing to Code 46
Registering a Service Worker 52
Service Worker Scope 60
The Service Worker Lifecycle 60
Wrap-Up 66
Chapter 4: Resource Caching 67
Service Worker Cache Interface 67
Preparing to Code 69
Caching Application Resources 70
Implementing Additional Caching Strategies 91
Wrap-Up 98
Chapter 5: Going the Rest of the Way Offline with Background Sync 99
Introducing Background Sync 100
Offline Data Sync 103
Choosing a Sync Database 105
Preparing to Code 110
Enhancing the PWA News Application 111
Wrap-Up 128
Chapter 6: Push Notifications 129
Introducing Push Notifications 129
Remote Notification Architecture 132
Preparing to Code 134
Generating Encryption Keys 134
Validating Notification Support 138
Checking Notification Permission 138
Getting Permission for Notifications 139
Local Notifications 142
Notification Options 144
Subscribing to Notifications 148
Unsubscribing from Notifications 154
Remote Notifications 156
Dealing with Subscription Expiration 162
Sending Notifications to Push Services 162
Wrap-Up 164
Chapter 7: Passing Data between Service Workers and Web Applications 165
Preparing to Code 166
Send Data from a Web App to a Service Worker 167
Send Data from a Service Worker to a Web App 169
Two-Way Communication Using MessageChannel 171
Wrap-Up 180
Chapter 8: Assessment, Automation, and Deployment 181
Assessing PWA Quality Using Lighthouse 181
Preparing to Code 182
PWABuilder 190
PWAs and the Microsoft Store 202
Wrap-Up 205
Chapter 9: Automating Service Workers with Google Workbox 207
Introducing Workbox 207
Generating a Precaching Service Worker 208
Add Precaching to an Existing Service Worker 215
Controlling Cache Strategies 218
Wrap-Up 224
Index 225