GithubHelp home page GithubHelp logo

kryndex / sw-toolbox Goto Github PK

View Code? Open in Web Editor NEW

This project forked from googlechromelabs/sw-toolbox

0.0 2.0 0.0 1.12 MB

A collection of service worker tools for offlining runtime requests

Home Page: https://googlechrome.github.io/sw-toolbox/

License: Apache License 2.0

Ruby 0.08% JavaScript 96.85% HTML 3.07%

sw-toolbox's Introduction

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.

Install

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:

navigator.serviceWorker.register('my-service-worker.js');

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.

Support

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.

License

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

http://www.apache.org/licenses/LICENSE-2.0

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.

sw-toolbox's People

Contributors

addyosmani avatar cvan avatar dandv avatar davidscales avatar garbee avatar gierschv avatar jeffposnick avatar jpmedley avatar mickeywu avatar mohsen1 avatar nickiaconis avatar psimyn avatar samertm avatar shantanuraj avatar tusharmath avatar wibblymat avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.