mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-03 04:10:27 +08:00
缓存策略增加“允许读取不完整的Partial Content”选项
This commit is contained in:
@@ -29,11 +29,12 @@ func FindCachePolicy(parent *actionutils.ParentAction, cachePolicyId int64) (*se
|
||||
if len(resp.HttpCachePolicyJSON) == 0 {
|
||||
return nil, errors.New("cache policy not found")
|
||||
}
|
||||
config := &serverconfigs.HTTPCachePolicy{}
|
||||
var config = &serverconfigs.HTTPCachePolicy{}
|
||||
err = json.Unmarshal(resp.HttpCachePolicyJSON, config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return config, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -37,11 +37,12 @@ func (this *CreatePopupAction) RunPost(params struct {
|
||||
FileEnableSendfile bool
|
||||
FileMinFreeSizeJSON []byte
|
||||
|
||||
CapacityJSON []byte
|
||||
MaxSizeJSON []byte
|
||||
FetchTimeoutJSON []byte
|
||||
SyncCompressionCache bool
|
||||
EnableMMAP bool
|
||||
CapacityJSON []byte
|
||||
MaxSizeJSON []byte
|
||||
FetchTimeoutJSON []byte
|
||||
SyncCompressionCache bool
|
||||
EnableMMAP bool
|
||||
EnableIncompletePartialContent bool
|
||||
|
||||
Description string
|
||||
IsOn bool
|
||||
@@ -95,10 +96,11 @@ func (this *CreatePopupAction) RunPost(params struct {
|
||||
MemoryPolicy: &serverconfigs.HTTPCachePolicy{
|
||||
Capacity: memoryCapacity,
|
||||
},
|
||||
OpenFileCache: openFileCacheConfig,
|
||||
EnableSendfile: params.FileEnableSendfile,
|
||||
MinFreeSize: minFreeSize,
|
||||
EnableMMAP: params.EnableMMAP,
|
||||
OpenFileCache: openFileCacheConfig,
|
||||
EnableSendfile: params.FileEnableSendfile,
|
||||
MinFreeSize: minFreeSize,
|
||||
EnableMMAP: params.EnableMMAP,
|
||||
EnableIncompletePartialContent: params.EnableIncompletePartialContent,
|
||||
}
|
||||
case serverconfigs.CachePolicyStorageMemory:
|
||||
options = &serverconfigs.HTTPMemoryCacheStorage{}
|
||||
|
||||
@@ -59,6 +59,14 @@ func (this *UpdateAction) RunGet(params struct {
|
||||
cachePolicy.Options["enableMMAP"] = false
|
||||
}
|
||||
}
|
||||
|
||||
// fix enableIncompletePartialContent
|
||||
{
|
||||
_, ok := cachePolicy.Options["enableIncompletePartialContent"]
|
||||
if !ok {
|
||||
cachePolicy.Options["enableIncompletePartialContent"] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.Data["cachePolicy"] = cachePolicy
|
||||
@@ -87,7 +95,8 @@ func (this *UpdateAction) RunPost(params struct {
|
||||
SyncCompressionCache bool
|
||||
FetchTimeoutJSON []byte
|
||||
|
||||
EnableMMAP bool
|
||||
EnableMMAP bool
|
||||
EnableIncompletePartialContent bool
|
||||
|
||||
Description string
|
||||
IsOn bool
|
||||
@@ -146,10 +155,11 @@ func (this *UpdateAction) RunPost(params struct {
|
||||
MemoryPolicy: &serverconfigs.HTTPCachePolicy{
|
||||
Capacity: memoryCapacity,
|
||||
},
|
||||
OpenFileCache: openFileCacheConfig,
|
||||
EnableSendfile: params.FileEnableSendfile,
|
||||
MinFreeSize: minFreeSize,
|
||||
EnableMMAP: params.EnableMMAP,
|
||||
OpenFileCache: openFileCacheConfig,
|
||||
EnableSendfile: params.FileEnableSendfile,
|
||||
MinFreeSize: minFreeSize,
|
||||
EnableMMAP: params.EnableMMAP,
|
||||
EnableIncompletePartialContent: params.EnableIncompletePartialContent,
|
||||
}
|
||||
case serverconfigs.CachePolicyStorageMemory:
|
||||
options = &serverconfigs.HTTPMemoryCacheStorage{}
|
||||
|
||||
Reference in New Issue
Block a user