Service worker not over HTTP
parent
092cef08dd
commit
a6eff1e371
|
@ -56,11 +56,17 @@ safeRun(async () => {
|
||||||
|
|
||||||
// if (!isDesktop) {
|
// if (!isDesktop) {
|
||||||
// if (localStorage.getItem("disable_sw") !== "true") {
|
// if (localStorage.getItem("disable_sw") !== "true") {
|
||||||
navigator.serviceWorker
|
if (navigator.serviceWorker) {
|
||||||
.register(new URL("service_worker.ts", import.meta.url), { type: "module" })
|
navigator.serviceWorker
|
||||||
.then((r) => {
|
.register(new URL("service_worker.ts", import.meta.url), { type: "module" })
|
||||||
console.log("Service worker registered...");
|
.then((r) => {
|
||||||
});
|
console.log("Service worker registered...");
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
console.log(
|
||||||
|
"No launching service worker (not present, maybe because not running on localhost or over SSL"
|
||||||
|
);
|
||||||
|
}
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// }
|
// }
|
||||||
|
|
|
@ -2,11 +2,11 @@ import { manifest, version } from "@parcel/service-worker";
|
||||||
|
|
||||||
async function install() {
|
async function install() {
|
||||||
const cache = await caches.open(version);
|
const cache = await caches.open(version);
|
||||||
console.log("Installing", manifest, "version", version);
|
// console.log("Installing", manifest, "version", version);
|
||||||
await cache.addAll(manifest);
|
await cache.addAll(manifest);
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
self.skipWaiting(); // This automatically enables the service worker, preventing from caching stuff forever if there's a page open
|
self.skipWaiting(); // This automatically enables the service worker, preventing from caching stuff forever if there's a page open
|
||||||
console.log("Installed");
|
// console.log("Installed");
|
||||||
}
|
}
|
||||||
|
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
|
|
Loading…
Reference in New Issue