From 6ac7742a53b5eedfbdb48297c182c25b6c70b7ad Mon Sep 17 00:00:00 2001 From: heimanba <371510756@qq.com> Date: Wed, 6 Nov 2024 14:39:59 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20=E5=A6=82=E6=9E=9C?= =?UTF-8?q?=E8=BF=94=E5=9B=9Ecache-control=EF=BC=8C=E5=B9=B6=E4=B8=94?= =?UTF-8?q?=E5=8C=85=E5=90=ABno-cache=EF=BC=8C=E5=88=99=E4=B8=8D=E5=AF=B9h?= =?UTF-8?q?eader=E8=BF=9B=E8=A1=8C=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/wasm-go/extensions/frontend-gray/main.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/wasm-go/extensions/frontend-gray/main.go b/plugins/wasm-go/extensions/frontend-gray/main.go index 6b5dbdb36f..b1fce21443 100644 --- a/plugins/wasm-go/extensions/frontend-gray/main.go +++ b/plugins/wasm-go/extensions/frontend-gray/main.go @@ -72,6 +72,7 @@ func onHttpRequestHeaders(ctx wrapper.HttpContext, grayConfig config.GrayConfig, // 如果没有配置比例,则进行灰度规则匹配 if util.IsSupportMultiVersion(grayConfig) { deployment = util.FilterMultiVersionGrayRule(&grayConfig, grayKeyValue, requestPath) + log.Infof("multi version %v", deployment) } else { if isPageRequest { if grayConfig.TotalGrayWeight > 0 { @@ -172,8 +173,10 @@ func onHttpResponseHeader(ctx wrapper.HttpContext, grayConfig config.GrayConfig, log.Errorf("error status: %s, error message: %v", status, err) return types.ActionContinue } - - proxywasm.ReplaceHttpResponseHeader("Cache-Control", "no-cache, no-store, max-age=0, must-revalidate") + cacheControl, err := proxywasm.GetHttpResponseHeader("cache-control") + if err == nil && !strings.Contains(cacheControl, "no-cache") { + proxywasm.ReplaceHttpResponseHeader("cache-control", "no-cache, no-store, max-age=0, must-revalidate") + } frontendVersion, isFeVersionOk := ctx.GetContext(config.XPreHigressTag).(string) xUniqueClient, isUniqClientOk := ctx.GetContext(config.XUniqueClientId).(string)