Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
workbox-range-requests
Advanced tools
Package description
The workbox-range-requests npm package is a module that makes it easy to add support for efficiently handling partial content requests in service workers. It's part of the Workbox suite of tools, which are designed to make it easier to build offline-first Progressive Web Apps (PWAs). This package specifically deals with range requests, which are HTTP requests that include a Range header indicating which part of the content the client wants to receive. This is particularly useful for large files, like videos or audio, where the client might only need a portion of the file at a time.
Creating a range request handler
This code sample demonstrates how to create a route that handles .mp4 files using the RangeRequestsPlugin. When a range request is received for an MP4 file, the plugin will take care of slicing the appropriate chunk of the file and returning it to the client.
workbox.routing.registerRoute(
/\.mp4$/,
new workbox.rangeRequests.RangeRequestsPlugin()
);
Using RangeRequestsPlugin with a custom handler
This code sample shows how to use the RangeRequestsPlugin within a custom handler function. When a range request is received, the plugin's createPartialResponse method is used to generate the partial response from the cachedResponse.
workbox.routing.registerRoute(
/\.mp4$/,
async ({request, event}) => {
// Assume `cachedResponse` will be the Response from the cache.
const rangeRequestPlugin = new workbox.rangeRequests.RangeRequestsPlugin();
return rangeRequestPlugin.createPartialResponse(request, cachedResponse);
}
);
This package is similar to workbox-range-requests in that it also handles HTTP range requests. However, it is not specifically designed for service workers or offline-first PWAs. It's a more general-purpose library for node.js environments.
range-cache is another npm package that provides caching functionality for HTTP range requests. Unlike workbox-range-requests, which is designed to work within the context of a service worker, range-cache is meant to be used on the server-side to cache and serve partial content.
While not a direct alternative to workbox-range-requests, shaka-player is an open-source JavaScript library for adaptive media playback in HTML5. It handles network requests, including range requests, for media segments in the context of adaptive streaming. It's more complex and serves a broader purpose than workbox-range-requests.
Readme
This module's documentation can be found at https://developers.google.com/web/tools/workbox/modules/workbox-range-requests
FAQs
This library creates a new Response, given a source Response and a Range header value.
The npm package workbox-range-requests receives a total of 4,048,537 weekly downloads. As such, workbox-range-requests popularity was classified as popular.
We found that workbox-range-requests demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.