Next.js service worker triggers a lot of requests

Hello,

Billing for our Next.js project has increased a lot over the last month (x5) due to some misconfiguration. As we’re trying to understand the causes for this usage (which is still not clear) we have been digging into Vercel Monitoring.
It looks like our service worker (which we have not configured in any special way) is triggering a lot of requests and data transfer.

This doesn’t look normal to me. How can we mitigate this ?


Hi, @valfily! Welcome to the Vercel Community :handshake:

Thanks for your patience with this! Some ideas on troubleshooting:

Check your service worker’s cache configuration:

  1. Verify the cache duration and invalidation strategy
  2. Ensure proper cache headers are set
  3. Consider implementing cache versioning

Review your service worker registration:

  1. Make sure it’s not repeatedly registering/unregistering
  2. Check the update frequency settings
  3. Consider limiting the scope if possible

Monitor your service worker’s network requests:

  1. Use Chrome DevTools to inspect the service worker
  2. Look for any infinite loops or excessive fetching
  3. Check for unnecessary asset prefetching

If you could try these suggestions out, and get back to us with updates - that’d be super helpful!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.