售 价:¥
温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印
为你推荐
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
How to do it...
How it works...
Showing rich notifications
Getting ready
How to do it...
How it works...
Using the notification tag
Getting ready
How to do it...
How it works...
Implementing push clients
Getting ready
How to do it...
How it works...
Subscribing to push notifications
Getting ready
How to do it...
How it works...
Managing push notification quotas
Getting ready
How to do it...
How it works...
9. Looking at General Usage
Introduction
Taking immediate control of the page
Getting ready
How to do it...
How it works...
Working with slow responses
Getting ready
How to do it...
How it works...
Relaying messages
Getting ready
How to do it...
How it works...
Using a service worker as a proxy middleware
Getting ready
How to do it...
How it works...
Using a service worker with a live flowchart
Getting ready
How to do it...
How it works...
10. Improving Performance
Introduction
Performing network requests from a cache
Getting ready
How to do it...
How it works...
See also
Performing network requests from a network
Getting ready
How to do it...
How it works...
See also
Testing waitUntil
Getting ready
How to do it...
How it works...
Implementing background sync
Getting ready
How to do it...
How it works...
Sending forward requests
Getting ready
How to do it...
How it works...
Avoiding model fetching and render times
Getting ready
How to do it...
How it works...
Index
买过这本书的人还买过
读了这本书的人还在读
同类图书排行榜