Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

159
Views
Service-worker not intercepting first fetch call on initial load

I'm having an issue with my custom service-worker. It doesn't seem to be intercepting the first fetch req when the page is initially loaded (but all fetch reqs afterwards are intercepted correctly). However, if I reload the page, all fetch reqs are intercepted correctly by the service-worker. So the problem only exists on initial load of the page.

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

This "first-load" behavior is by design. ServiceWorkers can't intercept the initial requests until they enter the installing state and end with the activated state. One option is to first show users an "Installing..." page, wait for the SW to become active, and then refresh the page. The SW can then serve an "SW activated" page. See example: https://fetch-progress.anthum.com/sw-basic/ - sw-simple.js

// INTERCEPT:  /, /index.html, /index.htm 
if ([scope, scope + 'index.html', scope + 'index.htm'].includes(event.request.url)) {
  event.respondWith(fetch(scope + 'sw-installed.html'))
}
about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!