Category Archives: Uncategorized

Sw.JS

const CACHE_NAME = “phase14-cache-v1”;
const URLS_TO_CACHE = [
“/”,
“/index.html”,
“/manifest.json”,
“/service-worker.js”,
“/icon-192.png”,
“/icon-512.png”
];

self.addEventListener(“install”, event => {
event.waitUntil(
caches.open(CACHE_NAME).then(cache => {
return cache.addAll(URLS_TO_CACHE);
})
);
});

self.addEventListener(“fetch”, event => {
event.respondWith(
caches.match(event.request).then(response => {
return response || fetch(event.request);
})
);
});

self.addEventListener(“activate”, event => {
event.waitUntil(
caches.keys().then(cacheNames => {
return Promise.all(
cacheNames.map(cache => {
if (cache !== CACHE_NAME) {
return caches.delete(cache);
}
})
);
})
);
});

Manifest.json

{
“name”: “Phase 14 Governance PWA”,
“short_name”: “Phase14”,
“start_url”: “./index.html”,
“display”: “standalone”,
“background_color”: “#0f0f0f”,
“theme_color”: “#0f0f0f”,
“icons”: [
{
“src”: “icon-192.png”,
“sizes”: “192×192”,
“type”: “image/png”
},
{
“src”: “icon-512.png”,
“sizes”: “512×512”,
“type”: “image/png”
}
]
}