How to use workbox-navigation-preload - 1 common examples

To help you get started, we’ve selected a few workbox-navigation-preload 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 / document-caching / index.ts View on Github external
init(
    documentCachingOptions: DocumentCachingOptions = {
      maxDocumentsInCache: 10,
      maxAgeSecondsforDocumentsInCache: 5 * 24 * 60 * 60,
      timeoutSeconds: 3,
    },
    fallbackOfflinePageUrl?: string,
  ): AmpNavigationRoute {
    enableNagigationPreload();
    const navigationPreloadOptions: {
      whitelist?: Array;
      blacklist?: Array;
    } = {};

    // create regexp Array from parsing the string array
    if (documentCachingOptions.allowList) {
      navigationPreloadOptions.whitelist = documentCachingOptions.allowList;
    } else if (documentCachingOptions.denyList) {
      navigationPreloadOptions.blacklist = documentCachingOptions.denyList;
    }

    if (
      documentCachingOptions.timeoutSeconds &&
      documentCachingOptions.timeoutSeconds > 5
    ) {

workbox-navigation-preload

This library allows developers to opt-in to using Navigation Preload in their service worker.

MIT
Latest version published 10 days ago

Package Health Score

97 / 100
Full package analysis

Popular workbox-navigation-preload functions