if ('serviceWorker' in navigator) {
    var ranNum = Math.floor(Math.random() * 100000);
    navigator.serviceWorker.register(baseUrl + 'pwa-sw.js?v=' + ranNum).then((registration) => {
        // Registration was successful
        // console.log('ServiceWorker registration successful with scope:', registration.scope);
        if (registration.active && registration.active.state == "activated") {
            // console.log("Service Worker is activated");
            registration.active.postMessage({ type: 'params', time: lastCacheAt });
        }
    }).catch((error) => {
        // Registration failed
        console.error('ServiceWorker registration failed:', error);
    });
} else {
    console.log('service worker is not supported');
}

