Class: CachedRangeResponsePlugin

workbox-range-requests.CachedRangeResponsePlugin

classstatic

This class is meant to be automatically invoked as a plugin to a
RequestWrapper, which is used by the workbox-sw and workbox-runtime-caching modules. If you are not using workbox-sw or workbox-runtime-caching,
then using the
handleRangeRequest function directly is recommended.

Under the hood, this will call handleRangeRequest(), passing in the appropriate request and response objects.

Constructor

CachedRangeResponsePlugin

new CachedRangeResponsePlugin()

Example

const workboxSW = new WorkboxSW();
const cacheFirstRangeHandler = workboxSW.strategies.cacheFirst({
cacheName: 'range-requests',
// There's no need to instantiate the class; all methods are static.
plugins: [workbox.rangedRequests.CachedRangeResponsePlugin]
});
// Create a route which will match all requests that have a Range: header,
// and handle them using a cache-first strategy, taking the Range: header
// into account.
workboxSW.registerRoute(
({event}) => event.request.headers.has('range'),
cacheFirstRangeHandler
);