Here is my gulp task :
gulp.task('service-worker', ['clean:sw'], function (cb) {
swPrecache.write(path.join(global.config.offlineRoot, 'sw.js'), {
staticFileGlobs: [
global.config.offlineRoot + '/offline/**/*.{js,html,css,png,jpg,jpeg,gif,svg,ttf,woff,woff2}',
global.config.offlineRoot + '/manifest.json'
],
dynamicUrlToDependencies: {
'/app-shell': ['lib/views/layouts/app-shell.hbs'],
'/': [
'lib/views/layouts/main-layout.hbs',
'lib/views/index.hbs'
]
},
runtimeCaching: [
{
// See https://github.com/GoogleChrome/sw-toolbox#methods
urlPattern: /^\/(?!login|admin)/,
handler: 'networkOnly'
}
],
stripPrefix: global.config.offlineRoot,
stripPrefixMulti: {
"node_modules/": 'scripts/'
},
navigateFallback: '/app-shell',
navigateFallbackWhitelist: [/^\/(?!login|admin)/],
cacheId: "nodebeats",
// importScripts: ['scripts/sw-toolbox/sw-toolbox.js'],
verbose: true,
maximumFileSizeToCacheInBytes: 3097152, //3mb
handleFetch: true//(global.config.env === 'prod')
})
.then(cb)
.catch(function () {
cb();
});
});
From the above config, Login and admin route are fetched using network only and the index route is served from cache first, But I want it to be the network First since I am binding my page from the server side. So the dynamic data are not getting replicated in the app unless ctrl + f5