What's the difference between using the Service Worker Cache API and regular browser cache?

后端 未结 2 732
夕颜
夕颜 2020-12-23 16:05

In my Progressive Web App, should I be using the Cache API in a service worker for my static assets, or should I just rely on the browser\'s native cache control for these?

2条回答
  •  时光取名叫无心
    2020-12-23 16:55

    A major advantage of the service worker cache API is that it gives you more detailed control than the built-in browser cache does. For example, your service worker can cache multiple requests when the user first runs your web app, including assets that they have not yet visited. This will speed up subsequent requests. You can also implement your own cache control logic, ensuring that assets that are considered important are kept in the cache while deleting less-used data.

提交回复
热议问题