This is a demo site.
Use a package manager like npm or yarn to install dependencies and start the development server
# for npm users
npm install && npm start
# for yarn users
yarn && yarn start
This project was created with Create-React-App (CRA), by default CRA use Workbox to create the service worker, and use features as Strategies, Precaching, Runtime caching, and so on. You can find it in src/swWorkbox.js
.
Currently, the project is using a custom Service Worker, built with Vanilla JS, which you can modify to implement your own cache strategies. You can find it in public/swCustom.js
.
Service workers can run only over HTTPS connection, to see more you can visit this link.
To use Workbox or a custom service worker, just replace the file name in src/swRegister.js
window.addEventListener('load', () => {
const swUrl = `${process.env.PUBLIC_URL}/swCustom.js`;
To test with ngrok your custom service worker offline, you'll need:
- Download and install ngrok
- Serve the project
# for npm users npm start # for yarn users yarn start
- Once your local server is up, e.g. http://localhost:3000 you can deploy it over a HTTPS connection with ngrok
{path-of-ngrok-executable}/ngrok http 3000
- Finally, you can test your page offline and see what resources are being cached with browser DevTools