I've started playing around with ServiceWorker
in Google Chrome v38. I've set #enable-experimental-web-platform-features
to True
in about:config
and setup my localhost to serve requests over https://
.
My sw.js
file contains simple example:
// The SW will be shutdown when not in use to save memory,
// be aware that any global state is likely to disappear
console.log("SW startup");
self.addEventListener('install', function(event) {
console.log("SW installed");
});
self.addEventListener('activate', function(event) {
console.log("SW activated");
});
self.addEventListener('fetch', function(event) {
console.log("Caught a fetch!");
event.respondWith(new Response("Hello world!"));
});
and my app.js
file:
if ('serviceWorker' in navigator) {
console.log('registering sw.js');
navigator.serviceWorker.register('/static/js/sw.js').then(function(reg) {
console.log('Yey!', reg);
}, function(err) {
console.log('Boo!', err);
});
}
My console output is:
registering sw.js app.js:27
Boo!
DOMException: The Service Worker installation failed. {message: "The Service Worker installation failed.", name: "AbortError", code: 20, INDEX_SIZE_ERR: 1, DOMSTRING_SIZE_ERR: 2…} app.js:31
Any ideas how to troubleshoot this issue?