I register the service worker with this code:
// If the browser supports serviceWorker, and we haven't registered any - we'll register our: sw.js ..
if ('serviceWorker' in navigator && !navigator.serviceWorker.controller) {
navigator.serviceWorker.register('/sw.js').then(function(registrationObj) {
console.log('Registration object: ', registrationObj);
}).catch(function(error) {
// serviceWorker registration failed ..
console.log('Registration failed with ' + error);
});
} else {
console.log('Service worker already registered. Skip registration.')
};
I see my assets appear in the app cache. Then I go to the Application
tab in Chrome, choose Service Workers
, click offline
and refresh the page.
The page opens fine, but I get this in browser console:
http://www.screencast.com/t/1uodUTHM5ig
and this in the Service Worker debugger:
http://www.screencast.com/t/zmqHMi9RJ