From fd4ea8cfdbaefbeb1d60aa57ca90a3677aeec5f7 Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Sun, 17 Oct 2021 20:22:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0PURGE=E6=9F=90=E4=B8=AAURL?= =?UTF-8?q?=E7=BC=93=E5=AD=98=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/serverconfigs/http_cache_config.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pkg/serverconfigs/http_cache_config.go b/pkg/serverconfigs/http_cache_config.go index 1815e20..865af51 100644 --- a/pkg/serverconfigs/http_cache_config.go +++ b/pkg/serverconfigs/http_cache_config.go @@ -1,12 +1,17 @@ package serverconfigs -import "encoding/json" +import ( + "encoding/json" + "github.com/iwind/TeaGo/rands" +) type HTTPCacheConfig struct { IsPrior bool `yaml:"isPrior" json:"isPrior"` IsOn bool `yaml:"isOn" json:"isOn"` - AddStatusHeader bool `yaml:"addStatusHeader" json:"addStatusHeader"` // 是否增加命中状态Header + AddStatusHeader bool `yaml:"addStatusHeader" json:"addStatusHeader"` // 是否增加命中状态Header + PurgeIsOn bool `yaml:"purgeIsOn" json:"purgeIsOn"` // 是否允许使用Purge方法清理 + PurgeKey string `yaml:"purgeKey" json:"purgeKey"` // Purge时使用的Edge-Purge-Key CacheRefs []*HTTPCacheRef `yaml:"cacheRefs" json:"cacheRefs"` // 缓存配置 } @@ -18,6 +23,11 @@ func (this *HTTPCacheConfig) Init() error { return err } } + + if this.PurgeIsOn && len(this.PurgeKey) == 0 { + this.PurgeKey = rands.HexString(32) + } + return nil }