chore: update readme

This commit is contained in:
Ayo Ayco 2024-08-24 21:29:01 +02:00
parent 7de664c451
commit e35d2e9115

View file

@ -3,9 +3,9 @@
[![Package information: NPM version](https://img.shields.io/npm/v/@ayco/astro-sw)](https://www.npmjs.com/package/@ayco/astro-sw) [![Package information: NPM version](https://img.shields.io/npm/v/@ayco/astro-sw)](https://www.npmjs.com/package/@ayco/astro-sw)
[![Package information: NPM license](https://img.shields.io/npm/l/@ayco/astro-sw)](https://www.npmjs.com/package/@ayco/astro-sw) [![Package information: NPM license](https://img.shields.io/npm/l/@ayco/astro-sw)](https://www.npmjs.com/package/@ayco/astro-sw)
Use your own authored service worker with Astro. Use your own authored [service worker](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API) with Astro.
The integration accepts the path to your own authored [service worker](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API) and automatically injects dynamic variables such as `__assets` generated by Astro for caching. The integration accepts the path to your service worker and automatically injects dynamic variables such as `__assets` generated by Astro for caching.
It works on all Astro output options: `static`, `server`, or `hybrid`, and lets developers retain the flexibility for various [caching strategies](https://developer.chrome.com/docs/workbox/caching-strategies-overview/). It works on all Astro output options: `static`, `server`, or `hybrid`, and lets developers retain the flexibility for various [caching strategies](https://developer.chrome.com/docs/workbox/caching-strategies-overview/).
@ -114,7 +114,6 @@ The integration accepts a configuration object with the following properties
| esbuild | [BuildOptions](https://esbuild.github.io/api/) | optional | custom build options for your service worker script | | esbuild | [BuildOptions](https://esbuild.github.io/api/) | optional | custom build options for your service worker script |
| registrationHooks | object | optional | provide callbacks for various registration events; see section on [Registration Hooks](#registration-hooks) | | registrationHooks | object | optional | provide callbacks for various registration events; see section on [Registration Hooks](#registration-hooks) |
## Background
## Example sw.js
This integration was developed to support the Caching strategy needs of [Cozy](https://github.com/ayoayco/cozy) -- the modern reading companion for the Web. You can find an example service worker (`src/sw.mjs`) in the [repository](https://github.com/ayoayco/Cozy/blob/main/src/sw.mjs). This integration was developed to support the Caching strategy needs of [Cozy](https://github.com/ayoayco/cozy) -- the modern reading companion for the Web. You can find an example service worker (`src/sw.mjs`) in the [repository](https://github.com/ayoayco/Cozy/blob/main/src/sw.mjs).