永远不会触发服务工作者获取事件

Service worker fetch event is never fired

我正在使用 Laravel 开发渐进式 Web 应用程序。我已经提到 PWA with Laravel for developing. In that first I generated service worker, then updated laravel mix after that set manifest file. In the layout I checked for service worker and push notification support. After registering service worker, install and activate are successfully triggered but fetch event is never triggered even when the browser set to offline as in the image browser offline. Also referred this video PWA LARAVEL. Code for package.json file is as shown in the image: package.json code for webpack.config.js file is: webpack.config.js, section of code in the blade(view) for registering service worker is:service-worker registration。 Service Worker 在我的 laravel 项目的 public 文件夹中生成。我是 Laravel 和 PWA 的新手。谢谢。

我得到了答案。实际上,在我的 laravel 项目中,我已经从 url 中删除了 public。但是 service worker 将收到其域中所有内容的获取事件;也就是说,如果我们在 /example/sw.js 注册 service worker 文件,那么 service worker 只会看到 URL 以 /example/ 开头的页面的获取事件(即 /example/page1/,/example/page2/).所以我应该将我的 url 模式更改为 public。谢谢。