Vladimir Asked:2020-12-31 19:48:12 +0000 UTC2020-12-31 19:48:12 +0000 UTC 2020-12-31 19:48:12 +0000 UTC ServiceWorker 中的“获取”事件 772 对这样一个问题感兴趣,ServiceWorker 中的 fetch 事件在访问非源域时会触发吗?或者是否可以只处理对您的域的请求? javascript 1 个回答 Voted Best Answer Alexandr Tovmach 2020-01-01T20:36:08Z2020-01-01T20:36:08Z ServiceWorkers 支持从no-origin域缓存,但需要单独配置,并且域必须是https 要使用 ServiceWorkers,我建议使用Workbox(来自 Google 的一个包)。从 Google Cloud 缓存图像的这种实现: workbox.routing.registerRoute( /.*(?:googleapis|gstatic)\.com.*\.(png|gif|jpg|jpeg|svg)/, workbox.strategies.cacheFirst({ cacheName: 'images', }), );
ServiceWorkers 支持从
no-origin
域缓存,但需要单独配置,并且域必须是https
要使用 ServiceWorkers,我建议使用Workbox(来自 Google 的一个包)。从 Google Cloud 缓存图像的这种实现: