Skip to content

Instantly share code, notes, and snippets.

@FDSoftware
Created March 17, 2019 04:17
Show Gist options
  • Save FDSoftware/9660e6a693a01731914f70f11b47ca16 to your computer and use it in GitHub Desktop.
Save FDSoftware/9660e6a693a01731914f70f11b47ca16 to your computer and use it in GitHub Desktop.
merca para el polsaker
<head>
<link rel="manifest" href="./manifest.json">
<meta charset="utf-8">
<meta name="theme-color" content="#317EFB"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="msapplication-TileColor" content="#2F3BA2">
.....
{
"name": "Colegio Hogar San Mauricio: Intranet",
"short_name": "SM_Intranet",
"icons": [{
"src": "images/icons/icon-128x128.png",
"sizes": "128x128",
"type": "image/png"
}, {
"src": "images/icons/icon-144x144.png",
"sizes": "144x144",
"type": "image/png"
}, {
"src": "images/icons/icon-152x152.png",
"sizes": "152x152",
"type": "image/png"
}, {
"src": "images/icons/icon-192x192.png",
"sizes": "192x192",
"type": "image/png"
}, {
"src": "images/icons/icon-256x256.png",
"sizes": "256x256",
"type": "image/png"
}],
"start_url": "/index.html",
"display": "standalone",
"background_color": "#3E4EB8",
"theme_color": "#2F3BA2"
}
var dataCacheName = 'SM_Intranet1';
var cacheName = 'test-cache-1';
var filesToCache = [
'./',
'./about.html',
'./contac.html',
'./js/material.js',
'./js/material.min.js',
'./js/helper.js',
'./css/material_icon.css',
'./css/icon.woff2'
];
self.addEventListener('install', function(e) {
console.log('[ServiceWorker] Install');
e.waitUntil(
caches.open(cacheName).then(function(cache) {
console.log('[ServiceWorker] Caching app shell');
return cache.addAll(filesToCache);
})
);
});
self.addEventListener('activate', function(e) {
console.log('[ServiceWorker] Activate');
e.waitUntil(
caches.keys().then(function(keyList) {
return Promise.all(keyList.map(function(key) {
if (key !== cacheName && key !== dataCacheName) {
console.log('[ServiceWorker] Removing old cache', key);
return caches.delete(key);
}
}));
})
);
return self.clients.claim();
});
self.addEventListener('fetch', function(e) {
console.log('[ServiceWorker] Fetch', e.request.url);
e.respondWith(
caches.match(e.request).then(function(response) {
return response || fetch(e.request);
})
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment