How to use the workbox-cache-expiration.Plugin function in workbox-cache-expiration

To help you get started, we’ve selected a few workbox-cache-expiration examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ampproject / amp-sw / src / modules / amp-caching / index.ts View on Github external
ampAssetsCaching() {
    // Versioned Assets
    router.registerRoute(
      VERSIONED_ASSETS_RE,
      new CacheFirst({
        cacheName: VERSIONED_CACHE_NAME,
        plugins: [
          new Plugin({
            maxAgeSeconds: 14 * 24 * 60 * 60, // 14 days
          }),
        ],
      }),
    );

    // Unversioned runtimes
    router.registerRoute(
      UNVERSIONED_RUNTIME_RE,
      new StaleWhileRevalidate({
        cacheName: UNVERSIONED_CACHE_NAME,
        plugins: [
          new Plugin({
            maxAgeSeconds: 7 * 24 * 60 * 60, // 7 days
          }),
        ],
github ampproject / amp-sw / src / modules / amp-caching / index.ts View on Github external
cacheName: UNVERSIONED_CACHE_NAME,
        plugins: [
          new Plugin({
            maxAgeSeconds: 7 * 24 * 60 * 60, // 7 days
          }),
        ],
      }),
    );

    // Unversioned Extensions
    router.registerRoute(
      UNVERSIONED_EXTENSIONS_RE,
      new StaleWhileRevalidate({
        cacheName: UNVERSIONED_CACHE_NAME,
        plugins: [
          new Plugin({
            maxAgeSeconds: 24 * 60 * 60, // 1 day
          }),
        ],
      }),
    );
  }

workbox-cache-expiration

A service worker helper library that expires cached responses based on age or maximum number of entries.

MIT
Latest version published 6 years ago

Package Health Score

75 / 100
Full package analysis

Popular workbox-cache-expiration functions