Search⌘ K
AI Features

Functional Events of the Service Worker

Explore the core functional events of service workers such as fetch, push, notification interaction, sync, and message events. Understand how these events help manage offline capabilities, background synchronization, push notifications, and communication between service workers and web pages to create responsive and engaging progressive web applications.

The functional events of a service worker are related to the functional requirements of our app. Let’s explore them one by one.

The fetch event

The fetch event is triggered when:

  • A browser sends a fetch request for loading some assets (CSS, JS files).
  • A page-related JavaScript initiates a fetch request using the Fetch API.

But the fetch event is not triggered by the XMLHTTPRequest and the Ajax requests.

A service worker can work as a network proxy. Therefore, we can do the following actions:

...