mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2025-11-03 12:20:27 +08:00
缓存设置中可以设置缓存主域名,用来复用多域名下的缓存
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
14
pkg/serverconfigs/http_cache_key_config.go
Normal file
14
pkg/serverconfigs/http_cache_key_config.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user