Uruguay
function updateOnlineStatus(event) {
let condition = navigator.onLine ? 'online' : 'offline';
console.log(`Do smth. You are ${condition}`);
}
window.addEventListener('online', updateOnlineStatus);
window.addEventListener('offline', updateOnlineStatus);
{
reconnect: {
// How many seconds should we wait before rechecking.
initialDelay: 3,
// How long should we wait between retries.
delay: (1.5 * last delay, capped at 1 hour)
}
}
{
// Should we store and attempt to remake requests
// which fail while the connection is down.
requests: true,
}
// By default, Offline makes an XHR request
// to load your /favicon.ico
// You can change the URL it hits
// (respond with a quick 204 is perfect):
Offline.options = {checks: {xhr: {url: '/connection-test'}}};
window.onbeforeunload = function(e) {
let dialogText = `You are offline! Don't do it!`;
e.returnValue = dialogText;
return dialogText;
};
<script src="http://example.com/jquery.js"></script>
<link rel="stylesheet" href="http://assets.example.com/style.css"/>
<img src="http://img.example.com/logo.png"/>;
<p>Read this nice <a href="http://example.com/2014/12/24/">
new post on cats!</a></p>
<meta http-equiv="Content-Security-Policy"
content="upgrade-insecure-requests">
<meta http-equiv="Content-Security-Policy"
content="block-all-mixed-content">
self.addEventListener('install', function(event) {
event.waitUntil(
caches.open('my-cashe-v1').then(function(cache) {
return cache.addAll([
'/css/whatever-v3.css',
'/css/imgs/sprites-v6.png',
'/css/fonts/whatever-v8.woff',
'/js/all-min-v4.js'
// etc
]);
})
);
});
[
"./48065a15ae3a16e845a528a3c0467487.svg",
"./6beb3319398d06b0635871740330ac7b.svg",
"./8450ddeb645c18bff7890bccc95881a7.svg",
"./ba17b770588f23af1184e66179dc222d.svg",
"./2e030a00362fe30a27bc0750b0626797.svg",
"./3585e1891683a708eabb7ed43446cf82.svg",
"./main.e5d23aa4f5b56b06e5ec.bundle.js",
"./1.e5d23aa4f5b56b06e5ec.chunk.js",
"./main.e5d23aa4f5b56b06e5ec.css",
"./1.e5d23aa4f5b56b06e5ec.chunk.js.gz",
"./1.e5d23aa4f5b56b06e5ec.bundle.map.gz",
"./main.e5d23aa4f5b56b06e5ec.css.gz",
"./main.e5d23aa4f5b56b06e5ec.bundle.js.gz"
]
toolbox.router.get(/urlPattern/, handler, options);
class CustomHandler extends workbox.runtimeCaching.Handler {
handle({ event }) {
console.log('CustomHandler is handling', event);
}
}
self.addEventListener('install', function(event) {
event.waitUntil(
caches.open('mycashe-v1').then(function(cache) {
cache.addAll(
// large and unimportant resources
);
return cache.addAll(
// important resources
);
})
);
});
~
40 Mb/...
6393
3290
578