Options for the install function.

Hierarchy

Properties

cacheHost?: string

The Edgio hostname from which to prefetch cached content. This is only used when the origin site is not served from Edgio.

Example

example.com
forcePrefetchRatio?: number

The probability that a prefetch request will be relayed to the origin even if a response is not in the cache. Defaults to 0. This should be a number between 0 and 1.

includeCacheMisses: boolean

Set to true to include pages not in the edge cache when prefetching. By default, pages will only be prefetched if they are available in Edgio edge cache. Warning: setting this to true will cause a significant increase in traffic to the origin server.

The prefetcher observes the DOM for new elements that are added for potential prefetching. Observations are made to the document's child nodes and subtree. Attributes changes are not observed by default, but can be enabled with ObserveOptionsConfig.attributes. Additionally, you can disable the observer by setting ObserveOptionsConfig.disabled to true.

onServiceWorkerRegistered?: ((registration: ServiceWorkerRegistration) => void)

Type declaration

    • (registration: ServiceWorkerRegistration): void
    • This function is called when the service worker is registered.

      Parameters

      • registration: ServiceWorkerRegistration

        The ServiceWorkerRegistration object.

      Returns void

onServiceWorkerStateChange?: ((registration: ServiceWorkerRegistration) => void)

Type declaration

    • (registration: ServiceWorkerRegistration): void
    • This function is called when the service worker state changes.

      Parameters

      • registration: ServiceWorkerRegistration

        The ServiceWorkerRegistration object.

      Returns void

prefetchPatterns?: RegExp[]

Any link whose href path matches one of these patterns will have its href prefetched when the link becomes visible

Example

//products/(.+)/
prefetchURLs?: string[]

URLs to prefetch immediately

Example

/products/123
serviceWorkerPath?: string

The URL path on which the service worker is served.

Example

/service-worker.js
serviceWorkerScope?: string

The scope of the service worker.

Example

'/'

A list of config objects with selectors to watch for. When elements matching the selector are found, the specified callback is called.

Example

install({ watch: [{ selector: 'div.product-tile', callback: el => { const productId = el.getAttribute('data-product-id') const catId = document.getElementById('cat-listing').getAttribute('data-category-id') prefetch(/api/${catId}/${productId}, 'fetch') } }] })

Generated using TypeDoc