Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/workbox recipes #2664

Merged
merged 11 commits into from
Nov 13, 2020
Merged

Conversation

Snugug
Copy link
Contributor

@Snugug Snugug commented Nov 3, 2020

R: @jeffposnick @philipwalton

Fixes #2622

Adds an experimental workbox-recipes module that bundles the configuration for common recipes into config-optional function calls. Example of what default usage would look like:

import {
  pageCache,
  imageCache,
  staticResourceCache,
  googleFontsCache,
  offlineFallback,
} from 'workbox-recipes';
import { precacheAndRoute } from 'workbox-precaching';

// Include offline.html in the manifest
precacheAndRoute(self.__WB_MANIFEST);

// request.mode === 'navigate', network first,   'pages' cachename, 3s timeout, [0, 200] statuses
pageCache();

// request.destination === 'style' || 'script' || 'worker', stale while revalidate first,   'static-resources' cachename, [0, 200] statuses
staticResourceCache();

// request.destination === 'image', cache first,   'images' cachename,, [0, 200] statuses, 30 day max age, 60 max entries
imageCache();

// Same as https://developers.google.com/web/tools/workbox/guides/common-recipes
googleFontsCache();

// Same as https://developers.google.com/web/tools/workbox/guides/advanced-recipes#comprehensive_fallbacks, but just setCacheHandler, and pulling from precache match
offlineFallback();

Google Fonts cache and Image cache
Aligns with other work, can create multiple if need multiple instead of using .register
Allows you to use the dependency-installed Gulp to run tasks instead of a global Gulp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make recipes easier to consume
2 participants