Skip to content
A drop in service worker library to help your AMP pages gain network resiliency in 1 line
Branch: master
Clone or download
prateekbh fixing valid amp doc regexp and increasing unversion files lifeline (#16
)

* fixing valid amp doc regexp and increasing unversion files lifeline

* fixing cache length test

* fixing tests

* fix regexp
Latest commit d54c514 Feb 24, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
puppeteer-test first commit Jan 23, 2019
src
test
.gitignore first commit Jan 23, 2019
.prettierrc
.travis.yml
CODE_OF_CONDUCTING.md
CONTRIBUTING.md first commit Jan 23, 2019
LICENSE
package.json v0.1.1 Feb 6, 2019
readme.md Fix reference to the required attribute for prefetching (#14) Feb 10, 2019
webpack.config.js
yarn.lock

readme.md

build

AMP Service worker

AMP service worker is a service worker library for your AMP pages.

The project aims to bring network resiliency and other network related optimizations to any AMP page which is being controlled by this service worker. Core use cases:

  • Cache AMP scripts with a stale-while-revalidate strategy for a longer duration that http-headers.
  • Cache valid visited AMP documents, and serve only in case of flaky network conditions.
  • Cache assets which are critical to a page with a given strategy.
  • Prefetch outgoing links from an AMP page.
  • Cache an offline page in order to show when a user navigates to a page which was previously not visited.

Usage

In order to use this library user can include the library with an importScript in their service worker

importScripts('https://cdn.ampproject.org/sw/amp-sw.js');
AMP_SW.init();

Modules

The AMP service worker is built up of the following modules:

  1. AMP caching module
  2. Document caching module
  3. Asset caching module
  4. Link prefetch module
  5. Offline page module

The description of each module and their configuration options can be found inside their respective folder's README.

You can’t perform that action at this time.