Skip to content

Commit

Permalink
feat: 🎸 如果返回cache-control,并且包含no-cache,则不对header进行修改
Browse files Browse the repository at this point in the history
  • Loading branch information
heimanba committed Nov 6, 2024
1 parent 0186791 commit 6ac7742
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions plugins/wasm-go/extensions/frontend-gray/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 6ac7742

Please sign in to comment.