Service Worker Development Cookbook
eBook - ePub

Service Worker Development Cookbook

Sean Amarasinghe

Partager le livre
  1. 384 pages
  2. English
  3. ePUB (adapté aux mobiles)
  4. Disponible sur iOS et Android
eBook - ePub

Service Worker Development Cookbook

Sean Amarasinghe

DĂ©tails du livre
Aperçu du livre
Table des matiĂšres
Citations

À propos de ce livre

Build highly available and performant native web applications that seamlessly integrate with third-party APIs

About This Book

  • Get straight into the action with step-by-step recipes that show you how to put Service Workers to work
  • Find out what Service Workers can do for your app, then do it!
  • Get the first in-depth look at this important new feature for web developers

Who This Book Is For

Web developers, mobile application developers, and software engineers with any level of knowledge can use this book. You should be familiar with JavaScript and HTML.

What You Will Learn

  • Display a custom offline page
  • Cache critical resources for offline use
  • Implement offline Google Analytics
  • Get network responses offline
  • Implement push notifications
  • Improve performance of your app

In Detail

It would be nice to have web apps that work offline and send push notifications. This is now possible with Service Workers, which can add native-like functionality to your web apps without requiring a download.

This book will get your mobile and web apps functioning without Internet connectivity, improve performance and network interaction in order to increase the level of availability, and show you how to build performant applications that seamlessly integrate with third-party APIs.

We'll show you how to add Service Worker functionality to web apps and sites, access offline content through basic and advanced techniques, and build powerful interactive system notifications. We'll also teach you about cache functionality and assets to provide immediate load even over narrow connections. We conclude by giving you various tips to improve app performance, including the background sync technique.

By the end of this book, you'll know build high performing and faster web and mobile applications with Service Workers.

Style and approach

This book provides lots of task-oriented, practical, and inspiring ways to put Service Workers to work. Step-by-step instructions will guide you through every task.

Foire aux questions

Comment puis-je résilier mon abonnement ?
Il vous suffit de vous rendre dans la section compte dans paramĂštres et de cliquer sur « RĂ©silier l’abonnement ». C’est aussi simple que cela ! Une fois que vous aurez rĂ©siliĂ© votre abonnement, il restera actif pour le reste de la pĂ©riode pour laquelle vous avez payĂ©. DĂ©couvrez-en plus ici.
Puis-je / comment puis-je télécharger des livres ?
Pour le moment, tous nos livres en format ePub adaptĂ©s aux mobiles peuvent ĂȘtre tĂ©lĂ©chargĂ©s via l’application. La plupart de nos PDF sont Ă©galement disponibles en tĂ©lĂ©chargement et les autres seront tĂ©lĂ©chargeables trĂšs prochainement. DĂ©couvrez-en plus ici.
Quelle est la différence entre les formules tarifaires ?
Les deux abonnements vous donnent un accĂšs complet Ă  la bibliothĂšque et Ă  toutes les fonctionnalitĂ©s de Perlego. Les seules diffĂ©rences sont les tarifs ainsi que la pĂ©riode d’abonnement : avec l’abonnement annuel, vous Ă©conomiserez environ 30 % par rapport Ă  12 mois d’abonnement mensuel.
Qu’est-ce que Perlego ?
Nous sommes un service d’abonnement Ă  des ouvrages universitaires en ligne, oĂč vous pouvez accĂ©der Ă  toute une bibliothĂšque pour un prix infĂ©rieur Ă  celui d’un seul livre par mois. Avec plus d’un million de livres sur plus de 1 000 sujets, nous avons ce qu’il vous faut ! DĂ©couvrez-en plus ici.
Prenez-vous en charge la synthÚse vocale ?
Recherchez le symbole Écouter sur votre prochain livre pour voir si vous pouvez l’écouter. L’outil Écouter lit le texte Ă  haute voix pour vous, en surlignant le passage qui est en cours de lecture. Vous pouvez le mettre sur pause, l’accĂ©lĂ©rer ou le ralentir. DĂ©couvrez-en plus ici.
Est-ce que Service Worker Development Cookbook est un PDF/ePUB en ligne ?
Oui, vous pouvez accĂ©der Ă  Service Worker Development Cookbook par Sean Amarasinghe en format PDF et/ou ePUB ainsi qu’à d’autres livres populaires dans Informatik et Webservices & APIs. Nous disposons de plus d’un million d’ouvrages Ă  dĂ©couvrir dans notre catalogue.

Informations

Année
2016
ISBN
9781786465290
Édition
1

Service Worker Development Cookbook


Table of Contents

Service Worker Development Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
eBooks, discount offers, and more
Why subscribe?
Preface
What this book covers
What you need for this book
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Learning Service Worker Basics
Introduction
Service workers
Promises
Promise.resolve(value)
Promise.reject(reason)
Setting up service workers
Getting ready
How to do it...
Chrome
Firefox
Setting up SSL for Windows
Getting ready
How to do it...
Setting up SSL for Mac
Getting ready
How to do it...
Setting up GitHub pages for SSL
Getting ready
How to do it...
Registering a service worker
Getting ready
How to do it...
How it works...
There's more...
Known issues
The ERR_FILE_EXISTS error message
Stale console messages
Registering a service worker in detail
Getting ready
How to do it...
How it works...
There's more...
Install
Activate
Fetch
Terminate
See also
Debugging
Getting ready
How to do it...
There's more...
Providing a stale version on error
Getting ready
How to do it...
How it works...
There's more...
Creating mock responses
Getting ready
How to do it...
How it works...
Handling request timeouts
Getting ready
How to do it...
How it works...
There's more...
2. Working with Resource Files
Introduction
Displaying a custom offline page
Getting ready
How to do it...
How it works...
There's more...
See also
Loading images offline
Getting ready
How to do it...
How it works...
There's more...
Handling responsive images
The srcset attribute
Device-pixel ratio
The sizes attribute
The picture element
See also
Loading CSS offline
Getting ready
How to do it...
How it works...
Loading fonts offline
Getting ready
How to do it...
How it works...
There's more...
See also
Implementing multiple fetch handlers
Getting ready
How to do it...
How it works...
There's more...
See also
Fetching remote resources
Getting ready
How to do it...
How it works...
There's more...
No credentials by default
Non-CORS fail by default
See also
3. Accessing Offline Content
Introduction
Caching critical resources for offline use
Getting ready
How to do it...
How it works...
See also
Showing cached content first
Getting ready
How to do it...
How it works...
Implementing a cache and network race
Getting ready
How to do it...
How it works...
Using window.caches
Getting ready
How to do it...
How it works...
Implementing stale-while-revalidate
Getting ready
How to do it...
How it works...
4. Accessing Offline Content with Advanced Techniques
Introduction
Templating
Getting ready
How to do it...
How it works...
See also
Implementing read-through caching
Getting ready
How to do it...
How it works...
Allowing offline Google Analytics
Getting ready
How to do it...
How it works...
See also
Allowing offline user interaction
Getting ready
How to do it...
How it works...
Implementing selective caching
Getting ready
How to do it...
How it works...
See also
5. Reaching Beyond the Offline Cache
Introduction
Getting network responses offline
Getting ready
How to do it...
How it works...
Caching content from ZIP
Getting ready
How to do it...
How it works...
Selecting the best content provider (load balancer)
Getting ready
How to do it...
How it works...
Redirecting a request
Getting ready
How to do it...
How it works...
Setting request headers
Getting ready
How to do it...
How it works...
Making a service worker act like a remote server
Getting ready
How to do it...
How it works...
Making a service worker act as a dependency injector
Getting ready
How to do it...
How it works...
Forcing immediate control
Getting ready
How to do it...
How it works...
Implementing fallback responses
Getting ready
How to do it...
How it works...
Deferring offline requests
Getting ready
How to do it...
How it works...
See also
6. Working with Advanced Libraries
Introduction
Working with global APIs
Getting ready
How to do it...
How it works...
Cache
caches
fetch
getAll
Implementing a circuit breaker
Getting ready
How to do it...
How it works...
Implementing a dead letter queue
Getting ready
How to do it...
How it works...
Logging API analytics
Getting ready
How to do it...
How it works...
Working with Google Analytics
Getting ready
How to do it...
How it works...
See also
7. Fetching Resources
Introduction
Fetching remote resources
Getting ready
How to do it...
How it works...
Fetching with FetchEvent
Getting ready
How to do it...
How it works...
Cache.addAll()
ExtendableEvent.waitUntil()
FetchEvent.respondWith()
Fetching a JSON file during service worker installation
Getting ready
How to do it...
How it works...
Proxying
Getting ready
How to do it...
How it works...
Prefetching
Getting ready
How to do it...
How it works...
8. Experimenting with Web Push
Introduction
Implementing a simple push notification
Getting ready
...

Table des matiĂšres