0.1.0 • Published 4 years ago

postsw v0.1.0

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

postsw

Simple post-processing Service Worker.

Installation

npm install -g postsw

Getting started

Register Service Worker

Add the following code to your project.

if ('serviceWorker' in navigator) {
  window.addEventListener('load', () => {
    navigator.serviceWorker.register('/sw.js');
  });
}

Or use with register-service-worker

Run

postsw ./your_project_dist_dir

# postsw --help

Server configuration(optional)

location / {
  index /index.html
  add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
  expires off;
}

location ~ (sw.js)$ {
  add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
  expires off;
}