It's online. It's offline. It's a Service Worker!
JavaScript HTML CSS
Switch branches/tags
Nothing to show
Clone or download
Permalink
Failed to load latest commit information.
_recipe_template Adding common assets for offline strategies recipes Sep 19, 2016
api-analytics Use ellipsis character instead of three points Dec 28, 2015
cache-from-zip zip cache use case: grammar fix Mar 20, 2017
cache-then-network Use // comments in Cache then Network (#309) Jul 23, 2018
dependency-injector Update eslint-config-airbnb to version 4 Jan 23, 2016
fetching Relying on html client rectangle for determining the iframe size Sep 17, 2016
imgs/random Adding common assets for offline strategies recipes Sep 19, 2016
immediate-claim fix typo Mar 1, 2016
json-cache README cleanup for consistency Dec 8, 2015
live-flowchart Updating screenshot URLs Feb 22, 2016
load-balancer Clarifying how to use the demo Dec 11, 2015
local-download update ui Mar 26, 2018
message-relay Removed more warnings. Feb 27, 2017
offline-fallback README cleanup for consistency Dec 8, 2015
offline-status README cleanup for consistency Dec 8, 2015
push-clients Fix push-clients TTL Apr 12, 2018
push-get-payload Run subscribe only when serviceWorker.ready resolves Apr 12, 2018
push-payload Run subscribe only when serviceWorker.ready resolves Apr 12, 2018
push-quota Run subscribe only when serviceWorker.ready resolves Apr 12, 2018
push-replace Run subscribe only when serviceWorker.ready resolves Apr 12, 2018
push-rich Run subscribe only when serviceWorker.ready resolves Apr 12, 2018
push-simple Run subscribe only when serviceWorker.ready resolves Apr 12, 2018
push-subscription-management Cleanup push-subscription-management Apr 13, 2018
render-store Add proxy to images as well Dec 30, 2015
request-deferrer Update eslint-config-airbnb to version 4 Jan 23, 2016
src Add iOS-specific styles to make scrolling smoother May 24, 2018
strategy-cache-and-update Cache and update strategy Oct 5, 2016
strategy-cache-only Cache only strategy Oct 5, 2016
strategy-cache-update-and-refresh Cache, update and refresh strategy Oct 5, 2016
strategy-embedded-fallback Changing the name of the recipe too. Oct 13, 2016
strategy-network-or-cache Network or cache strategy Oct 5, 2016
virtual-server Relying on html client rectangle for determining the iframe size Sep 17, 2016
.eslintignore Add root files to .eslintignore (we don't need them to be 80 char max) Nov 26, 2015
.eslintrc Update eslint-config-airbnb to version 4 Jan 23, 2016
.gitignore - First recipes, auto-claim and offline fallback Sep 29, 2015
.travis.yml Drop support for Node 4 Feb 6, 2018
LICENSE Initial commit Sep 22, 2015
Procfile amend Sep 30, 2015
README.md Fix formatting in README.md (#310) Jul 31, 2018
favicon.ico Favicon Sep 29, 2015
gulpfile.js Merge pull request #294 from slokhorst/push-vapid Mar 28, 2018
package.json Drop support for Node 4 Feb 6, 2018
parseRecipes.js Adding common assets for offline strategies recipes Sep 19, 2016
server.js Fix #190 - Remove index.html from homepage URL Mar 30, 2016
tools.js Add tools.js, required for Push recipes Mar 3, 2018

README.md

ServiceWorker Cookbook

Build Status dependencies devdependencies

It's online. It's offline. It's a Service Worker!

Service workers are a new technology to aid developers in:

  • creating realistic, reliable offline experiences
  • vastly improving performance when online
  • logically and dynamically caching files for any purpose

The ServiceWorker API, which has recently made its way into Firefox Developer Edition, will change the way web and mobile app developers make their websites fast and functional!

What is in this cookbook?

This cookbook contains dozens of practical, detailed, and working examples of service worker usage. These examples are for developers from beginner to expert and illustrate a number of APIs:

How to contribute

We are always happy to accept contributions! You can follow the process below to start creating a new recipe:

  1. Clone this repository
  2. Execute cd serviceworker-cookbook && npm install
  3. Copy the _recipe_template directory, rename it, and add all recipe code and resources within that new directory
  4. Execute gulp watch to start the server
  5. Navigate to http://localhost:3000 to develop and test your recipe

When it's all done, please submit a pull request to the ServiceWorker Cookbook.

Similar projects & prior art

Attributions

MealKeeper Icon by Shlyapnikova, Creative Commons (Attribution 3.0 Unported)

Attribution of pictures in Caching strategies category can be found at lorempixel.com.