mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2025-11-20 01:30:25 +08:00
可以在缓存条件里设置Expires Header
This commit is contained in:
@@ -13,12 +13,13 @@ type HTTPCacheRef struct {
|
|||||||
IsOn bool `yaml:"isOn" json:"isOn"`
|
IsOn bool `yaml:"isOn" json:"isOn"`
|
||||||
CachePolicyId int64 `yaml:"cachePolicyId" json:"cachePolicyId"`
|
CachePolicyId int64 `yaml:"cachePolicyId" json:"cachePolicyId"`
|
||||||
|
|
||||||
Key string `yaml:"key" json:"key"` // 每个缓存的Key规则,里面可以有变量
|
Key string `yaml:"key" json:"key"` // 每个缓存的Key规则,里面可以有变量
|
||||||
Life *shared.TimeDuration `yaml:"life" json:"life"` // 时间
|
Life *shared.TimeDuration `yaml:"life" json:"life"` // 时间
|
||||||
Status []int `yaml:"status" json:"status"` // 缓存的状态码列表
|
ExpiresTime *HTTPExpiresTimeConfig `yaml:"expiresTime" json:"expiresTime"` // 客户端过期时间
|
||||||
MinSize *shared.SizeCapacity `yaml:"minSize" json:"minSize"` // 能够缓存的最小尺寸
|
Status []int `yaml:"status" json:"status"` // 缓存的状态码列表
|
||||||
MaxSize *shared.SizeCapacity `yaml:"maxSize" json:"maxSize"` // 能够缓存的最大尺寸
|
MinSize *shared.SizeCapacity `yaml:"minSize" json:"minSize"` // 能够缓存的最小尺寸
|
||||||
Methods []string `yaml:"methods" json:"methods"` // 支持的请求方法
|
MaxSize *shared.SizeCapacity `yaml:"maxSize" json:"maxSize"` // 能够缓存的最大尺寸
|
||||||
|
Methods []string `yaml:"methods" json:"methods"` // 支持的请求方法
|
||||||
|
|
||||||
SkipResponseCacheControlValues []string `yaml:"skipCacheControlValues" json:"skipCacheControlValues"` // 可以跳过的响应的Cache-Control值
|
SkipResponseCacheControlValues []string `yaml:"skipCacheControlValues" json:"skipCacheControlValues"` // 可以跳过的响应的Cache-Control值
|
||||||
SkipResponseSetCookie bool `yaml:"skipSetCookie" json:"skipSetCookie"` // 是否跳过响应的Set-Cookie Header
|
SkipResponseSetCookie bool `yaml:"skipSetCookie" json:"skipSetCookie"` // 是否跳过响应的Set-Cookie Header
|
||||||
|
|||||||
16
pkg/serverconfigs/http_expires_time_config.go
Normal file
16
pkg/serverconfigs/http_expires_time_config.go
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||||
|
|
||||||
|
package serverconfigs
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
|
||||||
|
)
|
||||||
|
|
||||||
|
// HTTPExpiresTimeConfig 发送到客户端的过期时间设置
|
||||||
|
type HTTPExpiresTimeConfig struct {
|
||||||
|
IsPrior bool `yaml:"isPrior" json:"isPrior"` // 是否覆盖父级设置
|
||||||
|
IsOn bool `yaml:"isOn" json:"isOn"` // 是否启用
|
||||||
|
Overwrite bool `yaml:"overwrite" json:"overwrite"` // 是否覆盖
|
||||||
|
AutoCalculate bool `yaml:"autoCalculate" json:"autoCalculate"` // 是否自动计算
|
||||||
|
Duration *shared.TimeDuration `yaml:"duration" json:"duration"` // 周期
|
||||||
|
}
|
||||||
@@ -13,9 +13,10 @@ const (
|
|||||||
TimeDurationUnitMinute TimeDurationUnit = "minute"
|
TimeDurationUnitMinute TimeDurationUnit = "minute"
|
||||||
TimeDurationUnitHour TimeDurationUnit = "hour"
|
TimeDurationUnitHour TimeDurationUnit = "hour"
|
||||||
TimeDurationUnitDay TimeDurationUnit = "day"
|
TimeDurationUnitDay TimeDurationUnit = "day"
|
||||||
|
TimeDurationUnitWeek TimeDurationUnit = "week"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 时间间隔
|
// TimeDuration 时间间隔
|
||||||
type TimeDuration struct {
|
type TimeDuration struct {
|
||||||
Count int64 `yaml:"count" json:"count"` // 数量
|
Count int64 `yaml:"count" json:"count"` // 数量
|
||||||
Unit TimeDurationUnit `yaml:"unit" json:"unit"` // 单位
|
Unit TimeDurationUnit `yaml:"unit" json:"unit"` // 单位
|
||||||
@@ -33,6 +34,8 @@ func (this *TimeDuration) Duration() time.Duration {
|
|||||||
return time.Duration(this.Count) * time.Hour
|
return time.Duration(this.Count) * time.Hour
|
||||||
case TimeDurationUnitDay:
|
case TimeDurationUnitDay:
|
||||||
return time.Duration(this.Count) * 24 * time.Hour
|
return time.Duration(this.Count) * 24 * time.Hour
|
||||||
|
case TimeDurationUnitWeek:
|
||||||
|
return time.Duration(this.Count) * 24 * 7 * time.Hour
|
||||||
default:
|
default:
|
||||||
return time.Duration(this.Count) * time.Second
|
return time.Duration(this.Count) * time.Second
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user