create-react-app - 如何在 Create-React-App 2 中更改 PWA 工作箱缓存策略

标签 create-react-app progressive-web-apps workbox

Create-react-app v2 使用 workbox cacheFirst 策略。我想使用 staleWhileRevalidate。如何创建自定义 Service Worker 并将其添加为现有应用程序?

最佳答案

请更新至 create-react-app v4 如果你想更多地控制你的服务 worker 。
您可以启动一个将使用服务工作线程的新项目,您可以对其进行更改:

npx create-react-app my-app --template cra-template-pwa
详情在current documentation .

关于create-react-app - 如何在 Create-React-App 2 中更改 PWA 工作箱缓存策略,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53079734/

相关文章:

android - 在 PWA 中,虚拟键盘与 html 元素重叠,在移动 chrome 浏览器中则不会

javascript - 工作箱缓存版本控制最佳实践

node.js - @typescript-eslint/eslint-plugin@2.3.2 : The engine "node" is incompatible with this module

npm - 类型错误 : Class constructor {class} cannot be invoked without 'new'

typescript - typescript d.ts 文件中的枚举

javascript - 是否可以将装饰器与 create-react-app 一起使用?

service-worker - 用户登出后能否向用户发送推送通知?

javascript - 如何从 Service Worker 中删除多个打开的缓存