Network Status - Golden Dream
No Internet Connection
Please check your internet connection and try again. We'll keep trying to reconnect automatically.
You are Online
Great! You're connected to the internet. You can continue using Golden Dream.
const CACHE_NAME = "offline-cache-v1"; const BASE_URL = "https://goldendream.in/"; const urlsToCache = [BASE_URL + "noInternet/index.html", BASE_URL + "noInternet/sw.js", BASE_URL + "landing/landing_assets/images/gdLogo.png"]; // Install event - cache the required files self.addEventListener("install", (event) => { event.waitUntil( caches.open(CACHE_NAME).then((cache) => { console.log("Opened cache"); return cache.addAll(urlsToCache); }) ); }); // Activate event - clean up old caches self.addEventListener("activate", (event) => { event.waitUntil( caches.keys().then((cacheNames) => { return Promise.all( cacheNames.map((cacheName) => { if (cacheName !== CACHE_NAME) { return caches.delete(cacheName); } }) ); }) ); }); // Fetch event - serve from cache if offline self.addEventListener("fetch", (event) => { event.respondWith( caches.match(event.request).then((response) => { // Cache hit - return response if (response) { return response; } return fetch(event.request) .then((response) => { // Check if we received a valid response if (!response || response.status !== 200 || response.type !== "basic") { return response; } // Clone the response const responseToCache = response.clone(); caches.open(CACHE_NAME).then((cache) => { cache.put(event.request, responseToCache); }); return response; }) .catch(() => { // If both cache and network fail, show offline page if (event.request.mode === "navigate") { return caches.match(BASE_URL + "noInternet/index.html"); } }); }) ); });