From 880582bb4f68833612c6aeec9de83d338c8efae0 Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Thu, 16 Dec 2021 17:38:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=BA=90=E7=AB=99=E6=B2=A1=E6=9C=89=E5=9C=B0?= =?UTF-8?q?=E5=9D=80=E6=97=B6=E4=B9=9F=E5=B0=9D=E8=AF=95Stale=20Cache/?= =?UTF-8?q?=E9=81=BF=E5=85=8Dwrite50x()=E6=96=B9=E6=B3=95=E8=BF=9B?= =?UTF-8?q?=E5=85=A5=E6=AD=BB=E5=BE=AA=E7=8E=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/nodes/http_request_cache.go | 4 +++- internal/nodes/http_request_reverse_proxy.go | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/nodes/http_request_cache.go b/internal/nodes/http_request_cache.go index d653921..b470ad0 100644 --- a/internal/nodes/http_request_cache.go +++ b/internal/nodes/http_request_cache.go @@ -18,6 +18,8 @@ import ( // 读取缓存 func (this *HTTPRequest) doCacheRead(useStale bool) (shouldStop bool) { + this.cacheCanTryStale = false + cachePolicy := this.Server.HTTPCachePolicy if cachePolicy == nil || !cachePolicy.IsOn { return @@ -167,7 +169,7 @@ func (this *HTTPRequest) doCacheRead(useStale bool) (shouldStop bool) { // cache相关变量 this.varMapping["cache.status"] = "MISS" - if this.web.Cache.Stale != nil && this.web.Cache.Stale.IsOn { + if !useStale && this.web.Cache.Stale != nil && this.web.Cache.Stale.IsOn { this.cacheCanTryStale = true } return diff --git a/internal/nodes/http_request_reverse_proxy.go b/internal/nodes/http_request_reverse_proxy.go index 687f358..2ffa85b 100644 --- a/internal/nodes/http_request_reverse_proxy.go +++ b/internal/nodes/http_request_reverse_proxy.go @@ -61,7 +61,7 @@ func (this *HTTPRequest) doReverseProxy() { if origin.Addr == nil { err := errors.New(this.requestFullURL() + ": origin '" + strconv.FormatInt(origin.Id, 10) + "' does not has a address") remotelogs.Error("HTTP_REQUEST_REVERSE_PROXY", err.Error()) - this.write50x(err, http.StatusBadGateway, false) + this.write50x(err, http.StatusBadGateway, true) return } this.RawReq.URL.Scheme = origin.Addr.Protocol.Primary().Scheme()