tezvyn:

Service Worker Registration: Claiming Your Control Scope

Source: developer.mozilla.orgbeginner

Registering a service worker is like assigning a security guard (your script) to a specific area (the scope) of your site for offline support. The footgun: by default, a worker can only control its own directory, not the whole site.

Registering a service worker is like assigning a security guard (your script) to a specific area (the scope) of your site. This `register()` call is the first step for enabling offline support or push notifications. The biggest footgun is scope: by default, a worker at `/js/sw.js` can only control pages under `/js/`. To control the entire site (`/`), you must explicitly set the scope and use a special `Service-Worker-Allowed` HTTP header.

Read the original → developer.mozilla.org

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.

Service Worker Registration: Claiming Your Control Scope · Tezvyn