简体   繁体   English

Service Worker 缓存与 HTTP 缓存

[英]Service worker cache vs HTTP cache

I disabled service workers in couple of production websites, I can see resource load time is better when using HTTP cache (from disk cache & from memory cache) than with service workers (from serviceworker) when I debug using Chrome devtools (Network tab).我在几个生产网站中禁用了 Service Worker,当我使用 Chrome devtools(网络选项卡)调试时,我可以看到使用 HTTP 缓存(来自磁盘缓存和来自内存缓存)的资源加载时间比使用 ServiceWorker(来自 serviceworker)要好。

I totally agree service workers gives better control over cache management and for offline usecase.我完全同意服务工作者可以更好地控制缓存管理和离线用例。

What other benefits Service worker has over HTTP cache ? Service Worker 比 HTTP 缓存还有什么其他好处?

I have the same question.我也有同样的问题。 I observed that when service worker is enabled, the "Request to Service worker" takes much longer or equal to than downloading content.我观察到当 Service Worker 启用时,“请求 Service Worker”比下载内容花费的时间长得多或等于。 And overall http cache was much faster.并且整体 http 缓存要快得多。 I am not using the fully offline capability of PWA.我没有使用 PWA 的完全离线功能。 Wondering if enabling service worker just for caching is harming performance instead of improving load time.想知道仅针对缓存启用 Service Worker 是否会损害性能而不是改善加载时间。 I tried to dig into details by doing a performance audit and checking the communication between main thread and service worker thread, I am guessing it is the communication which is asynchronous in nature and hence takes more time.我试图通过进行性能审计和检查主线程和服务工作线程之间的通信来深入了解细节,我猜这是本质上异步的通信,因此需要更多时间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM