优化Partial Content缓存

This commit is contained in:
GoEdgeLab
2022-11-19 21:20:53 +08:00
parent bd71d59b74
commit b1adc80c48
9 changed files with 69 additions and 40 deletions

View File

@@ -628,7 +628,14 @@ func (this *HTTPRequest) tryPartialReader(storage caches.StorageInterface, key s
}()
// 检查范围
const maxFirstSpan = 16 << 20 // TODO 可以在缓存策略中设置此值
for index, r := range ranges {
// 没有指定结束字节时,自动指定一个
if r.Start() >= 0 && r.End() == -1 {
if partialReader.MaxLength() > r.Start()+maxFirstSpan {
r[1] = r.Start() + maxFirstSpan
}
}
r1, ok := r.Convert(partialReader.MaxLength())
if !ok {
return nil, nil