question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Batching of precache requests to prevent net::ERR_INSUFFICIENT_RESOURCES in Chrome

See original GitHub issue

Library Affected: This likely is only related to workbox-precache

Browser & Platform: Google Chrome

Issue or Feature Request Description: I originally wrote this as a comment on #570, but I since that issue is closed, I thought I would post it as a new issue to get more visibility

It seems that workbox uses Promise.all when making precache requests instead of explicitly batching or rate-limiting the requests, and it seems that Chrome can’t handle this under certain circumstances.

Specifically, I’m getting sporadic net::ERR_INSUFFICIENT_RESOURCES failures.

Screen Shot 2020-06-02 at 1 35 10 AM

After looking up this error, it seems that this represents some sort of resource exhaustion within chrome. A few other people have come across this here, and here, and it seems that the answer is to simply make fewer concurrent requests.

I noticed that @nachoab came up against this here and solved it by batching requests in chunks of 20, effectively limiting concurrency to 20 inflight requests at most… but that’s against the old sw-precache repo and not directly applicable here.

The easiest and most flexible solution as I see it would be to make precacheAndRoute (or just precache) return a promise that resolves when all of the specified routes have been precached. This way I could do the rate-limiting in my serviceworker, instead of adding the burden of rate-limiting onto workbox.

Thoughts?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
micahjoncommented, May 7, 2021

I appreciate the simplicity of downloading assets one by one and the goal of reducing impact on other network requests, but it would be nice if this was configurable.

For instance, imagine you’re pre-caching some data (e.g. API request) that isn’t available at the edge in your user’s region. Now retrieving that data from the other side of the world holds up all your other assets at the edge from pre-caching, when they could easily happen in parallel with a negligible performance impact if you allowed two requests at a time.

Latency aside, this also negates some HTTP/2 benefits, even in the simple case of all assets being at the edge already.

In my case, I have a lot of smallish assets and one large XML file, which holds everything else up. Not the end of the world, but it would be nice if I could expand the pipeline to 2-3 requests at a time.

0reactions
jshearercommented, Jul 1, 2020

Fantastic!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Precaching dos and don'ts - Chrome Developers
Learn the do's and don'ts of precaching. ... relying on a network-first or network-only caching strategy to deal with navigation requests.
Read more >
Preload, Prefetch And Priorities in Chrome - Medium
Preload is an early fetch instruction to the browser to request a resource needed for a page (key scripts, Web Fonts, hero images)....
Read more >
Clear, enable, and manage cookies in Chrome - Google Support
Clear, enable, and manage cookies in Chrome. You can choose to delete existing cookies, allow or block all cookies, and set preferences for...
Read more >
Fast playback with audio and video preload - web.dev
Link preload, Forces the browser to make a request for a video ... Note that starting in Chrome 64, the default value for...
Read more >
[Feature Request] Option to disable cache for certain file types
To unsubscribe from this group and stop receiving emails from it, send an email to google-chrome-developer-tools+unsub...@googlegroups.com. To ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found