缓存条件增加If-None-Match和If-Modified-Since是否回源选项;默认不回源,防止源站返回304

This commit is contained in:
刘祥超
2022-08-07 16:37:29 +08:00
parent 28cb3c383d
commit e3cf111344
2 changed files with 10 additions and 2 deletions

View File

@@ -1389,12 +1389,12 @@ func (this *HTTPRequest) Cookie(name string) string {
return c.Value return c.Value
} }
// DeleteHeader 删除Header // DeleteHeader 删除请求Header
func (this *HTTPRequest) DeleteHeader(name string) { func (this *HTTPRequest) DeleteHeader(name string) {
this.RawReq.Header.Del(name) this.RawReq.Header.Del(name)
} }
// SetHeader 设置Header // SetHeader 设置请求Header
func (this *HTTPRequest) SetHeader(name string, values []string) { func (this *HTTPRequest) SetHeader(name string, values []string) {
this.RawReq.Header[name] = values this.RawReq.Header[name] = values
} }

View File

@@ -70,6 +70,14 @@ func (this *HTTPRequest) doOriginRequest(failedOriginIds []int64, failedLnNodeId
// 强制变更原来访问的域名 // 强制变更原来访问的域名
requestHost = this.ReqHost requestHost = this.ReqHost
} }
// 回源Header中去除If-None-Match和If-Modified-Since
if !this.cacheRef.EnableIfNoneMatch {
this.DeleteHeader("If-None-Match")
}
if !this.cacheRef.EnableIfModifiedSince {
this.DeleteHeader("If-Modified-Since")
}
} }
// 自定义源站 // 自定义源站