Service worker responds slowly (10 seconds) when many query parameters are present
See original GitHub issueLibrary Affected: workbox-strategies
Browser & Platform: Google Chrome v101.0.4951.41
Issue or Feature Request Description:
On a site using the PWA plugin for WordPress, which includes Workbox, the service worker is taking 10 seconds for the NetworkFirst strategy to respond to requests for URLs that have many query parameters.
Steps to reproduce:
- Go to https://www.sensorsone.com/ and let the service worker install
- Try reloading the page and see it only takes a couple seconds.
- Now try going to the same URL with many query parameters, and notice that the response from the service worker takes over 10 seconds.
- Now in the Application tab of DevTools, enable “Bypass for Network” and reload the same URL with many query parameters. Now the response is returned relatively quickly as in the first step.
Originally reported on the WordPress plugin support forum
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Long URL with many query parameters slowing loading
Hi, I'm finding the PWA plugin is slowing the loading of long URL with many query parameters ~30. The length of one I...
Read more >Service Worker slow response times - google chrome
In the project we have here, there are static resources served with high cache expirations set, and we use query parameters (repository revision ......
Read more >Troubleshoot slow SQL Server performance caused by I/O ...
Provides a methodology to isolate and troubleshoot SQL performance problems caused by slow disk I/O.
Read more >Service worker configuration - Angular
This topic describes the properties of the service worker configuration file. ... Therefore, the patterns will partially match the request URLs.
Read more >Any way to speed up really slow refresh times in Power Query?
Another site said to enable the Fast Data Load under Query Options. I've done that, but it doesn't seem to help much. Is...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is due to the
denylist
functionality in the service worker’s navigation routing:The following RegExps are each being tested against the long
pathname
+search
:/^\/wp\-admin($|\?.*|\/.*)/
/[^\?]*.\.php($|\?.*)/
/.*\?(.*&)?(wp_service_worker)=/
/.*\/wp\.serviceworker(\?.*)?$/
/[^\?]*\/feed\/(\w+\/)?$/
/\?(.+&)*wp_customize=/
/\?(.+&)*customize_changeset_uuid=/
/^\/wp\-json\/.*/
I can’t tell you offhand which one of them is giving you particularly bad performance when tested against that long input, but it normally tends to be a RegExp that does a bunch of backtracking. You could try removing them one by one from your
denylist
until you find the one(s) that are expensive, and then attempt to optimize it.I’m going to close this issue, since it appears to be more about how Workbox is configured than about the core functionality. Let me know if there’s anything else I can do to assist, though.
Thanks a lot! I was able to identify these two patterns as causing the expensive backtracing:
I’m going to optimize those and then consider your improved denial logic for the future.
🙇