GOOD SHELL MAS BOY
Server: Apache/2.4.52 (Ubuntu)
System: Linux vmi1836763.contaboserver.net 5.15.0-130-generic #140-Ubuntu SMP Wed Dec 18 17:59:53 UTC 2024 x86_64
User: www-data (33)
PHP: 8.4.10
Disabled: NONE
Upload Files
File: /var/www/app.ayokah.co.uk/public/sw.js
// Define a cache name
const CACHE_NAME = 'ayokah-cache-v1';

// Files to cache
const URLS_TO_CACHE = [
    '/',
    '/assets/css/vendors/swiper-bundle.min.css',
    '/assets/css/vendors/bootstrap.min.css',
    '/assets/css/vendors/remixicon.css',
    '/assets/css/style.css',
    '/assets/js/bootstrap.bundle.min.js',
    '/assets/js/swiper-bundle.min.js',
    '/assets/js/custom-swiper.js',
    '/assets/js/onload-modal.js',
    '/assets/js/script.js',
];

// Install event
self.addEventListener('install', (event) => {
    event.waitUntil(
        caches.open(CACHE_NAME)
            .then((cache) => {
                console.log('Opened cache');
                return cache.addAll(URLS_TO_CACHE);
            })
    );
});

// Fetch event
self.addEventListener('fetch', (event) => {
    event.respondWith(
        caches.match(event.request)
            .then((response) => {
                // Return cached response if available, otherwise fetch from network
                return response || fetch(event.request);
            })
    );
});

// Activate event
self.addEventListener('activate', (event) => {
    const cacheWhitelist = [CACHE_NAME];
    event.waitUntil(
        caches.keys().then((cacheNames) => {
            return Promise.all(
                cacheNames.map((cacheName) => {
                    if (cacheWhitelist.indexOf(cacheName) === -1) {
                        return caches.delete(cacheName);
                    }
                })
            );
        })
    );
});