@gmod/http-range-fetcher (英语)
HTTP 字节范围请求的缓存/ 管理器, 将请求合并到一起并 缓存结果 。 为请求很多小字节范围的应用程序所设计 超过经常相邻的HTTP.
工作在节点或网络包装/浏览验证。 尊重 HTTP 缓存语义
除外,对于下列请求,设定最低1秒的默认TTL:
并非真的应该被缓存( 例如) . Cache-Control: no-cache) (中文(简体) ). 你可以转身
通过设置取消行为 minimumTTL 倒计时.
安装
$ npm install --save http-range-fetcher
使用量
const { HttpRangeFetcher } = require('http-range-fetcher')
const cache = new HttpRangeFetcher({})
cache.getRange('http://foo.bar/baz.bam', 20, 10).then(response => {
assert(response.buffer.length === 10)
assert(response.headers['content-range'] === '20-29/23422')
// response objects contain `headers` and `buffer`. the `headers` object
// contains the original headers that came from the server in response to the
// aggregated call, except the Content-Range header has been overwritten
// to match the requested range, and it adds a X-Resource-Length header that
// conveniently gives the total length of the remote resource so you don't
// have to parse the Content-Range header.
assert(response.headers['x-resource-length'] === '23422')
})
// these will be aggregated behind the scenes
// as a single request for a big chunk of the remote file,
// which will be cached to satisfy subsequent requests
Promise.all([
cache.getRange('http://foo.bar/baz.bam', 20, 10),
cache.getRange('http://foo.bar/baz.bam', 30, 10),
cache.getRange('http://foo.bar/baz.bam', 40, 10),
cache.getRange('http://foo.bar/baz.bam', 50, 10),
cache.getRange('http://foo.bar/baz.bam', 60, 10),
cache.getRange('http://foo.bar/baz.bam', 70, 10),
]).then(fetchResults => {
fetchResults.forEach(res => assert(res.buffer.length === 10))
})
目录
学术用途
这一一揽子计划是利用来自 (原始内容存档于2018-09-21) (韩语). NHGRI 作为 页:1 J 浏览 项目。 如果你在学术中使用它 请引用最近发表的JBrowse论文 链接从 jbrowse.org (英语)。 。 。 .
许可证
麻省理工学院 罗伯特·布厄尔斯
说明
2024年更名为 http-range-fetcher - > @gmod/http-range-fetcher