3.0.0
What's New?
sw-toolbox
Integration
sw-precache
is meant to be used hand-in-hand with a runtime caching library like sw-toolbox
, with sw-precache
handling your App Shell and sw-toolbox
handling your dynamic content.
Previously, using them both together required installing the sw-toolbox
package separately and pulling it in via the importScripts
option, which made a common use case overly complicated.
Now, it's possible to automatically include and configure sw-toolbox
via a new sw-precache
option, runtimeCaching
. You can configure both your App Shell and dynamic caching strategies in one location, along the lines of:
var config = {
runtimeCaching: [{
// See https://github.com/GoogleChrome/sw-toolbox#methods
urlPattern: /runtime-caching/,
handler: 'cacheFirst',
// See https://github.com/GoogleChrome/sw-toolbox#options
options: {
cache: {
maxEntries: 1,
name: 'runtime-cache'
}
}
}],
staticFileGlobs: [
rootDir + '/css/**.css',
rootDir + '/**.html',
rootDir + '/images/**.*',
rootDir + '/js/**.js'
]
};
The gulpfile.js
in the demo/
directory includes a complete sample of configuring both App Shell and dynamic content caching.
Getting Started Guide
The Getting Started Guide lays out some common terminology and helps developers understand how to think about the specific caching needs of their web app.
External Config for sw-precache
Command Line
Developers who prefer using the command line sw-precache
binary can now store their configuration in an external JSON file. This makes it much easier to use a complex configuration without having to wrangle command line flags.