https://github.com/nftstorage/nftstorage-service-worker
***Notice: This repository is no longer maintained.***
https://github.com/nftstorage/nftstorage-service-worker
Last synced: 4 months ago
JSON representation
***Notice: This repository is no longer maintained.***
- Host: GitHub
- URL: https://github.com/nftstorage/nftstorage-service-worker
- Owner: nftstorage
- Created: 2022-05-02T19:20:42.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-05-04T23:45:55.000Z (about 4 years ago)
- Last Synced: 2024-12-31T02:24:25.500Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 34.2 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# nftstorage-service-worker
A service worker to fetch content from IPFS via nftstorage.link or a fallback gateway if it ever gets blocked.
nftstorage.link is a fast IPFS gateway. Sometimes the entire domain gets completely blocked by Google Safe Browsing, which leaves sites that link to it unable to get their content. This service worker fixes that by trying to fetch the content via nftstorage.link first, and if there is an error, fetching from alternate IPFS gateways instead. FAST & ROBUST!
## Getting started
- Copy `nftstorage-sw.js` into the root of your static website project.
- Register the service worker from a script tag or your main js bundle.
```js
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('nftstorage-sw.js');
}
```
## Use with Webpack
For using `nftstorage-service-worker` on your project bundle with webpack, look into [webpack example](./example/webpack/).
## References
- https://github.com/olizilla/see-other - a sw to resolve mutable dnslinks to their current immutable form for better caching.
- https://github.com/ipfs-shipyard/service-worker-gateway - run js-ipfs in a service worker.