self.addEventListener('install', (event) => {
  event.waitUntil(
    caches.open('my-app-cache').then((cache) => {
      return cache.addAll([
        'index.php',
         'user/billing.php',
         'user/staff.php',
          'user/dashboard.php',
           'user/invoice.php',
            'user/login.php',
            'user/logout.php',
              'user/no_print.php',
                'user/print_sales.php',
                  'user/qrcode.php',
                    'user/report.php',
                      'user/save_sales.php',
                        'user/staff.php',
                          'user/update_status.php',
        'style.css',
        'user/assets/css/invoice.css',
        'user/assets/css/responsive.css',
        'user/assets/css/style.css',
        'user/assets/css/vendor.css',
        'piback/assigning.php',
        'piback/assigningcode.php',
        'piback/attendance.php',
        'piback/bilcode.php',
        'piback/bill_reset.php',
        'piback/branch.php',
        'piback/branch_print.php',
        'piback/branch_report.php',
        'piback/branchcode.php',
        'piback/captcha.php',
        'piback/company.php',
        'piback/companycode.php',
        'piback/consolidate_print.php',
        'piback/consolidate_report.php',
        'piback/customer.php',
        'piback/customercode.php',
        'piback/dashboard.php',
        'piback/footer.php',
        'piback/header.php',
        'piback/index.php',
        'piback/logout.php',
        'piback/product.php',
        'piback/productcode.php',
        'piback/registration.php',
        'piback/sales.php',
        'piback/service.php',
        'piback/servicecode.php',
        'piback/staff.php',
        'piback/staffcode.php',
        
        'script.js',
        'logo-192x192.png',
         'logo-512x512.png',   // Make sure logo.png exists in your directory
      ]);
    })
  );
});

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