service worker
service worker is javascript that can intercept the process to fetch resources.example
ServiceWorker.js
1. use the url as a key to match the resource from the cache.2. if the resource doesn't match, it'll be fetched from online and if the response is ok(200), put the resource to the cache.
- caches.has
- check existence of the cache
- caches.open
- get the cache
- cache.match
- match the resource from the cache
- cache.put
- put the resource to the cache
html/ServiceWorkerManager.js
- navigator.serviceWorker.register
- register the service worker
- navigator.serviceWorker.getRegistration
- get the service worker registration
- registration.unregister
- unregister the service worker
html/CacheManager.js
- caches.has
- check existence of the cache
- caches.open
- get the cache
- caches.delete
- delete the cache
- cache.keys
- get all keys used to match the resource from the cache
- cache.delete
- delete the resource from the cache
- cache.put
- put the resource to the cache