1.0.0 • Published 2 years ago

dynamic-cache v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Install

$ npm i dynamic-cache

API

Table of Contents

constructor

src/index.ts:58-62

Creates a DynamicCache.

const headers = new Headers({ 'Content-Type': 'text/plain' })
const cache = new DynamicCache('text', headers)

Parameters

  • namespace string Namespace of the files in this cache
  • headers Headers Headers to use for this cache files

put

src/index.ts:77-84

Puts a file in the cache.

const url = await cache.put('foo', 'bar')
await fetch(url).then(res => res.text()) // => "bar"

Parameters

  • filename string The filename of the resource
  • content string The content of the resource
  • headers Headers to be used (optional, default this.headers)

Returns any The full path of the resource, including the cache's prefix

register

src/index.ts:21-41

Registers the service worker.

// note you must serve `sw.js` at a higher level than your current url location
await DynamicCache.register('/sw.js')

Parameters

Contribute

Fork or edit and submit a PR.

All contributions are welcome!

License

MIT © 2021 stagas