hexo-offline
Out-of-the-box hexo offline experience
Last updated 2 years ago by jlhwung .
BSD-2-Clause · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install hexo-offline 
SYNC missed versions from official npm registry.

hexo-offline

npm version Build Status AppVeyor build status Coverage Status Dependencies Status Dev Dependencies Status

hexo-offline is intended to provide offline experience for hexo built static website. It uses ServiceWorker under the hood. Simply install this plugin to your website and it should be offline ready by caching most of static assets.

Demo

  • vuejs.org: Read Vuejs documentation in the flight.

Install

npm i hexo-offline --save

Once installed, run hexo clean && hexo generate to activate offline experience.

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.

While hexo-offline aims to provide zero-config offline enhancement to your hexo project, it does offer full list of options control from sw-precache. Simply add your configuration to the root _config.yml.

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

Again, the config is demonstration only and you don't have to copy and paste if you serves all contents from the origin server.

How if content is served via CDN?

Suppose that you have used two CDN scripts:

- https://cdn.example.com/script-name/script-version.js
- http://cdn.another-example.org/script-name/script-version.css

Add this config to root _config.yml

offline:
  runtimeCaching:
    - urlPattern: /*
      handler: cacheFirst
      options:
        origin: cdn.example.com
    - urlPattern: /*
      handler: cacheFirst
      options:
        origin: cdn.another-example.org

Note:

  1. As the CDN resources is runtime cached, it means that the resource will be cached only after a user-agent visit the page where the resource is referenced. Therefore, if you have included a CDN resource example.com/script.js in some-page.html only, the user who visit index.html only would not have example.com/script.js in cache.
  2. we use cacheFirst handler as CDN resources with specific version are not supposed to change in the future.

Current Tags

  • 1.0.0                                ...           latest (2 years ago)

8 Versions

  • 1.0.0                                ...           2 years ago
  • 0.2.3                                ...           3 years ago
  • 0.2.2                                ...           4 years ago
  • 0.2.1                                ...           4 years ago
  • 0.2.0                                ...           4 years ago
  • 0.1.3                                ...           4 years ago
  • 0.1.1                                ...           4 years ago
  • 0.1.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 3
This Month 99
Last Day 3
Last Week 33
Last Month 80
Dependencies (1)
Dev Dependencies (11)
Dependents (2)

Copyright 2014 - 2017 © taobao.org |