Search code examples
cachingcross-browserservice-workerandroid-browser

Getting "failed to load resources :ERR_INSUFFICIENT_RESOURCES" error while loading Service Worker in Chrome/Opera browsers on Android


I'm using Service Worker to make a hybrid application to run offline, so I added all links necessary in my SW to run my app offline.

It is working fine in Chrome and Opera on desktop but in Android I am getting this error "failed to load resources ERR_INSUFFICIENT_RESOURCES" in both the browsers.

I added around 1000 links which includes various .css, .js, .html and image files which are to be cached. After around 10-20 files, for remaining files I'm getting this error for each file and browser is getting crashed.

When checked in chrome://crashes I can see the crashes being registered and it says "The size on the local storage is 453KB (varies randomly for every crash)", but I'm not even using local storage until I registered SW.

Is there any limit for SW to be used in Android browsers or there is some other problem preventing it from registering SW.


Solution

  • Finally I found the problem, the issue is when SW requested 1000 files at a time, mobile browser can't handle those many requests in one go and hence the error.

    We generally use cache.addAll(urlsToCache) instead we need to call cache.add(urlsToCache[index++]) recursively.