hexo-service-worker

1.0.1 • Public • Published

hexo-service-worker

npm version Build Status

hexo-service-worker a hexo plugin for built one offline static website. and add some detail for cache contorl.

Install

npm i hexo-service-worker --save

Once installed, run hexo clean && hexo generate to activate plugin.

Usage

If the website serves all content from the origin server, you don't have to add any config. Simply install and run hexo clean && hexo generate.

add config to your _config.yml like this.

# offline config passed to sw-precache. 
service_worker:
  maximumFileSizeToCacheInBytes: 5242880
  staticFileGlobs:
  - public/**/*.{js,html,css,png,jpg,gif,svg,eot,ttf,woff,woff2}
  stripPrefix: public
  verbose: true

if you have CDN resource

- https://cdn.some.com/some/path/some-script.js
- http://cdn.some-else.org/some/path/deeply/some-style.css

Add this config to root _config.yml

service_worker:
  runtimeCaching:
    urlPattern: /*
      handler: cacheFirst
      options:
        origin: cdn.some.com
    urlPattern: /*
      handler: cacheFirst
      options:
        origin: cdn.some-else.org

Readme

Keywords

none

Package Sidebar

Install

npm i hexo-service-worker

Weekly Downloads

1

Version

1.0.1

License

MIT

Last publish

Collaborators

  • zoumiaojiang