Skip to content

patchjs/patchjs-sw

Repository files navigation

Introduction

enhance the ability of service worker.

sw.js example

importScripts('./sw-core.js');

sw.config({
  cacheId: 'cachedb',
  precache: [
  	'./images/test.png',
  	'https://gw.alipayobjects.com/zos/rmsportal/CtJlgAZbmyeSCLxqsgqF.png'
  ],
}).run();

Options

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.


About

enhance the ability of service worker.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published