enhance the ability of service worker.
importScripts('./sw-core.js');
sw.config({
cacheId: 'cachedb',
precache: [
'./images/test.png',
'https://gw.alipayobjects.com/zos/rmsportal/CtJlgAZbmyeSCLxqsgqF.png'
],
}).run();
cacheId String
default cachedb
cache name.
precache Array
default []
pre-cached list.
urlRule RegRex
default /https?:\/\/.+\.(jpg|gif|png|jpeg|webp|js|css)$/
the URL rules will be cached.
requestErr Function
default noop
when the request is error, the callback will be triggered.
exceedQuotaErr Function
default noop
when the quota isn't enough, trigger the function of exceedQuotaErr.
patchjs.increment Boolean
default true
It enables the incremental load.
patchjs.urlRule RegRex
default /\d+\.\d+\.\d+\/.+\.(css|js)$/
the URL rules will be cached by Patch.js.