mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-07 18:50:27 +08:00
缓存策略增加“允许读取不完整的Partial Content”选项
This commit is contained in:
@@ -1004,6 +1004,11 @@ func (this *FileStorage) CanSendfile() bool {
|
|||||||
return this.options.EnableSendfile
|
return this.options.EnableSendfile
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Options 获取当前缓存存储的选项
|
||||||
|
func (this *FileStorage) Options() *serverconfigs.HTTPFileCacheStorage {
|
||||||
|
return this.options
|
||||||
|
}
|
||||||
|
|
||||||
// 获取Key对应的文件路径
|
// 获取Key对应的文件路径
|
||||||
func (this *FileStorage) keyPath(key string) (hash string, path string, diskIsFull bool) {
|
func (this *FileStorage) keyPath(key string) (hash string, path string, diskIsFull bool) {
|
||||||
hash = stringutil.Md5(key)
|
hash = stringutil.Md5(key)
|
||||||
|
|||||||
@@ -722,6 +722,10 @@ func (this *HTTPRequest) tryPartialReader(storage caches.StorageInterface, key s
|
|||||||
ranges[0][1] < 0 &&
|
ranges[0][1] < 0 &&
|
||||||
!partialReader.IsCompleted() {
|
!partialReader.IsCompleted() {
|
||||||
if partialReader.BodySize() > 0 {
|
if partialReader.BodySize() > 0 {
|
||||||
|
var options = this.ReqServer.HTTPCachePolicy.Options
|
||||||
|
if options != nil {
|
||||||
|
fileStorage, isFileStorage := storage.(*caches.FileStorage)
|
||||||
|
if isFileStorage && fileStorage.Options() != nil && fileStorage.Options().EnableIncompletePartialContent {
|
||||||
var r = ranges[0]
|
var r = ranges[0]
|
||||||
r2, findOk := partialReader.Ranges().FindRangeAtPosition(r.Start())
|
r2, findOk := partialReader.Ranges().FindRangeAtPosition(r.Start())
|
||||||
if findOk && r2.Length() >= (256<<10) /* worth reading */ {
|
if findOk && r2.Length() >= (256<<10) /* worth reading */ {
|
||||||
@@ -732,6 +736,8 @@ func (this *HTTPRequest) tryPartialReader(storage caches.StorageInterface, key s
|
|||||||
return pReader, ranges, r2.End() - 1 /* not include last byte */, true
|
return pReader, ranges, r2.End() - 1 /* not include last byte */, true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user