缓存设置中可以设置缓存主域名,用来复用多域名下的缓存

This commit is contained in:
GoEdgeLab
2023-12-13 18:41:24 +08:00
parent 68a0f3fe31
commit 176196b222
10 changed files with 1399 additions and 916 deletions

View File

@@ -14,6 +14,8 @@ type HTTPCacheConfig struct {
EnableCacheControlMaxAge bool `yaml:"enableCacheControlMaxAge" json:"enableCacheControlMaxAge"` // 是否支持Cache-Control: max-age=...
DisablePolicyRefs bool `yaml:"disablePolicyRefs" json:"disablePolicyRefs"` // 是否停用策略中定义的条件
Key *HTTPCacheKeyConfig `yaml:"key" json:"key"` // 键值全局配置
PurgeIsOn bool `yaml:"purgeIsOn" json:"purgeIsOn"` // 是否允许使用Purge方法清理
PurgeKey string `yaml:"purgeKey" json:"purgeKey"` // Purge时使用的X-Edge-Purge-Key
@@ -30,6 +32,13 @@ func (this *HTTPCacheConfig) Init() error {
}
}
if this.Key != nil {
err := this.Key.Init()
if err != nil {
return err
}
}
if this.PurgeIsOn && len(this.PurgeKey) == 0 {
this.PurgeKey = rands.HexString(32)
}

View File

@@ -0,0 +1,14 @@
// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
package serverconfigs
// HTTPCacheKeyConfig 缓存Key配置
type HTTPCacheKeyConfig struct {
IsOn bool `yaml:"isOn" json:"isOn"`
Scheme string `yaml:"scheme" json:"scheme"`
Host string `yaml:"host" json:"host"`
}
func (this *HTTPCacheKeyConfig) Init() error {
return nil
}