Aditya Chhikara
Aditya Chhikara

Reputation: 13

Service worker implementation architecture?

I have to implement a service worker for my web site, which is a collection of pages with angularjs and non angularjs pages. Every angularjs page is an SPA with on page routing. So Please tell me if I have to write a single service worker for all the pages or I can write a separate service worker for every page? Thanks for the help.

Upvotes: 0

Views: 91

Answers (1)

Jeff Posnick
Jeff Posnick

Reputation: 56064

In general, creating a single, top-level service worker scoped to '/' should be sufficient. Inside that service worker's fetch event handler, you can examine the request's URL and mode (e.g. 'navigate') and take appropriate action depend on what subpage is being accessed.

Upvotes: 1

Related Questions