Socket
Socket
Sign inDemoInstall

workbox-core

Package Overview
Dependencies
0
Maintainers
6
Versions
84
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    workbox-core

This module is used by a number of the other Workbox modules to share common code.


Version published
Weekly downloads
4.4M
increased by0.78%
Maintainers
6
Install size
352 kB
Created
Weekly downloads
 

Package description

What is workbox-core?

The workbox-core package is a part of the Workbox suite of libraries and tools for service workers. It provides essential utilities and base classes that are used by other Workbox modules. It helps in managing service worker lifecycle, caching strategies, and request routing.

What are workbox-core's main functionalities?

Service Worker Lifecycle Management

This feature helps in managing the lifecycle of service workers. The `clientsClaim` method ensures that the service worker starts controlling all open clients as soon as it activates.

import { clientsClaim } from 'workbox-core';

self.addEventListener('activate', (event) => {
  event.waitUntil(clientsClaim());
});

Precaching

Although this feature is part of workbox-precaching, it relies on workbox-core for some of its functionality. It allows you to precache assets during the service worker installation phase.

import { precacheAndRoute } from 'workbox-precaching';

precacheAndRoute(self.__WB_MANIFEST);

Routing

This feature allows you to define custom routing rules for network requests. In this example, it uses the Stale-While-Revalidate strategy for caching images.

import { registerRoute } from 'workbox-routing';
import { StaleWhileRevalidate } from 'workbox-strategies';

registerRoute(
  ({request}) => request.destination === 'image',
  new StaleWhileRevalidate({
    cacheName: 'images',
  })
);

Other packages similar to workbox-core

Readme

Source

This module's documentation can be found at https://developers.google.com/web/tools/workbox/modules/workbox-core

Keywords

FAQs

Last updated on 11 Aug 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc