A service worker is a script that your browser runs in the
背景,独立于网页,打开大门的功能
that don't need a web page or user interaction. Today, they already
包括功能,如 push notifications和 background sync和有
ability to intercept and handle network requests包括
programmatically managing a cache of responses.
将来,服务人员可能会支持
periodic sync或 geofencing。
根据这个 创建反应应用程序
Service workers are introduced with create-react-app via
SWPrecacheWebpackPlugin.
Using a server worker with a cache-first strategy offers performance
advantages, since the network is no longer a bottleneck for fulfilling
导航请求。这确实意味着,但是,开发人员(和
用户)只会看到已部署的“ N + 1”更新
访问页,因为以前缓存的资源在
背景。
在新的应用程序中,对 register service worker的调用是默认启用的,但是你可以随时删除它,然后恢复正常行为。