sw-toolbox 0,9,0,7,0,9,3,5 Bower npm

A collection of service worker tools for offlining runtime requests

Service Worker Toolbox

Build Status Dependency Status devDependencies Status

A collection of tools for service workers

Service Worker Toolbox provides some simple helpers for use in creating your own service workers. Specifically, it provides common caching strategies for dynamic content, such as API calls, third-party resources, and large or infrequently used local resources that you don’t want precached.

Service Worker Toolbox provides an expressive approach to using those strategies for runtime requests. If you’re not sure what service workers are or what they are for, start with the explainer doc.

What if I need precaching as well?

Then you should go check out sw-precache before doing anything else. In addition to precaching static resources, sw-precache supports optional runtime caching through a simple, declarative configuration that incorporates Service Worker Toolbox under the hood.


Service Worker Toolbox is available through Bower, npm or direct from GitHub:

bower install --save sw-toolbox

npm install --save sw-toolbox

git clone https://github.com/GoogleChrome/sw-toolbox.git

Register your service worker

From your registering page, register your service worker in the normal way. For example:


As implemented in Chrome 40 or later, a service worker must exist at the root of the scope that you intend it to control, or higher. So if you want all of the pages under /myapp/ to be controlled by the worker, the worker script itself must be served from either / or /myapp/. The default scope is the containing path of the service worker script.

For even lower friction, you can instead include the Service Worker Toolbox companion script in your HTML as shown below. Be aware that this is not customizable. If you need to do anything fancier than register with a default scope, you’ll need to use the standard registration.

<script src="/path/to/sw-toolbox/companion.js" data-service-worker="my-service-worker.js"></script>

Add Service Worker Toolbox to your service worker script

In your service worker you just need to use importScripts to load Service Worker Toolbox:

importScripts('bower_components/sw-toolbox/sw-toolbox.js');  // Update path to match your own setup.

Use the toolbox

To understand how to use the toolbox read the Usage and API documentation.


If you’ve found an error in this library, please file an issue at https://github.com/GoogleChrome/sw-toolbox/issues.

Patches are encouraged, and may be submitted by forking this project and submitting a pull request through this GitHub repo.

Future of Service Worker tooling

Both sw-precache and sw-toolbox are actively maintained and we plan to continue supporting them. A large number of production Progressive Web Apps are successfully using them today and we are happy to review issues or PRs related to either project.

In parallel, we are working on the next generation of Service Worker tooling over in sw-helpers. This new work is more modular and will enable a number of libraries with additional capabilities to be built. We will announce further plans around the roadmap for this work in the future.


Copyright 2015-2016 Google, Inc.

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at


Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Related Repositories



A collection of service worker tools for offlining runtime requests ...



The kitchen sink of scripts to aid sw developers ...

Top Contributors

wibblymat jeffposnick gauntface jpmedley addyosmani adityapunjani nickiaconis dandv Garbee psimyn gierschv cvan


package version
path-to-regexp ^1.0.1
dev browserify ^13.1.0
chai ^3.4.1
chromedriver ^2.28.0
cookie-parser ^1.4.1
eslint ^3.13.1
eslint-config-google ^0.7.1
express ^4.13.3
geckodriver 1.6.1
gulp ^3.9.0
gulp-eslint ^3.0.1
gulp-gh-pages ^0.5.4
gulp-header ^1.8.8
gulp-sourcemaps ^2.3.1
gulp-uglify ^2.0.0
jsdoc ^3.4.0
mocha ^3.2.0
npm-publish-scripts ^4.1.16
operadriver ^1.0.0
selenium-assistant ^5.0.4
sw-testing-helpers ^1.0.2
temp ^0.8.3
vinyl-buffer ^1.0.0
vinyl-source-stream ^1.1.0
which ^1.2.4


-   v3.3.0 zip tar
-   v3.2.1 zip tar
-   v3.2.0 zip tar
-   v3.1.1 zip tar
-   v3.1.0 zip tar
-   v3.0.1 zip tar
-   v3.0.0 zip tar
-   v2.1.0 zip tar
-   v2.0.4 zip tar
-   v2.0.3 zip tar
-   v2.0.2 zip tar
-   v2.0.1 zip tar
-   v2.0.0 zip tar
-   v1.0.0 zip tar