Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

167
Views
Offline mode for service worker still fetches from server using Chrome offline mode

I am learning about PWAs/service workers and most tutorials either use the offline mode in the application or network tab to toggle the online state. They seem to have no issues yet when I toggle it offline, my service worker is still fetching from the server. The only true way I can get my fallback HTML to load is to stop my express server. I have also tried without any node environment and use live-server as a vscode extension but that too gives me the same result. I have to stop the live-server for it to realize I'm offline.

I've checked my fetch event code in sw.js which matches the tutorial so I don't see any reason for it not to work like others.

// fetch event
self.addEventListener('fetch', function onFetchReceived(evt) {
  // console.log(`Fetch event received`, evt);
  evt.respondWith(
    caches.match(evt.request).then(function fulfilled(cacheResponse) {
      return (
        cacheResponse ||
        fetch(evt.request)
          .then((fetchResponse) => {
            console.log('not found in cache, getting from server');
            return caches.open(dynamicCacheName).then((cache) => {
              cache.put(evt.request.url, fetchResponse.clone());
              return fetchResponse;
            });
          })
          .catch(() => {
            console.log('offline, unable to retrieve from server.');
            return caches.match('/pages/offline.html');
          })
      );
    })
  );
});
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!