In firefox browser service worker stooped sunndenly after serve the resources to the client

ramesh P 0 Reputation points

I have develop blazor WASM application for offline thats why I had implement the service worker to intercept the request then serve the resource to the client using cache. Service worker successfully on chrome and edge but in firebox once application load at the time service worker serve the resource to the client then with in 5-10 secs service worker stopped sunddenly and show the start button I had observe this on application tab with service worker on browser. It shows service stopped suddenly. If I had tried to run application offline i got this message on firefox browser that is Offline mode Firefox is currently in offline mode and can’t browse the Web. Press “Try Again” to switch to online mode and reload the page. If manually click start service worker then run offline not working.

I need run offline. service worker stoped in firefox


const cacheName = 'blazor-cache-v1';
const assetsToCache = [
    '/', // index.html
self.addEventListener('install', event => {
    event.waitUntil( => {
            return cache.addAll(assetsToCache);
self.addEventListener('fetch', event => {
        caches.match(event.request).then(cachedResponse => {
            if (cachedResponse) {
                // If a cached response is found, return it
                return cachedResponse;
            // Otherwise, fetch from network
            return fetch(event.request).then(networkResponse => {
                // Cache the new response and return it
                if (event.request.method === 'GET' && networkResponse.type === 'basic') {
                    return => {
                        cache.put(event.request, networkResponse.clone());
                        return networkResponse;
                } else {
                    return networkResponse;
self.addEventListener('activate', event => {
    const currentCaches = [cacheName];
        caches.keys().then(cacheNames => {
            return cacheNames.filter(cacheName => !currentCaches.includes(cacheName));
        }).then(cachesToDelete => {
            return Promise.all( => {
                return caches.delete(cacheToDelete);
        }).then(() => self.clients.claim())

A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,460 questions
JavaScript API
JavaScript API
An Office service that supports add-ins to interact with objects in Office client applications.
914 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce ( 59,546 Reputation points

    this is expected behavior. a server worker has a short timeout after it completed its work (activate event on page load, or fetch). chrome has a feature that if the dev tools are open, the service does not timeout.

    that is, normally when there is no work, the service for will stop. then restart on the next event it has registered

    your service worker has no code to support offline mode. it just a simple cache of some assets used to load the hosting page. you don't even cache the blazor wasm, so its not even a complete cache.