Slide 116
Slide 116 text
#WebPerformance / 6 avril 2017
@guillaumeehret
5
gulp.task('generate-service-worker', function(callback) {
let config = {
cacheId: 'dev-mind',
runtimeCaching: [{
urlPattern: '/(.*)',
handler: 'networkFirst',
options : {
networkTimeoutSeconds: 2,
maxAgeSeconds: 43200
}
}],
staticFileGlobs: [ `${paths.dist}/**/*.{js,html,css,png,jpg,json,gif,svg,webp,woff2}`],
stripPrefix: `${paths.dist}/`,
verbose: true
};
swPrecache.write(`${paths.tmp}/service-worker.js`, config, callback);
});