From 061253b4c3f307a70c54204c7a56cb513d3151ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Thu, 2 Dec 2021 09:54:48 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=93=E5=AD=98=E5=9C=A8=E5=93=8D=E5=BA=94?= =?UTF-8?q?=E4=B8=AD=E5=8F=AF=E4=BB=A5=E6=B7=BB=E5=8A=A0Age=20Header?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/nodes/http_request_cache.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/nodes/http_request_cache.go b/internal/nodes/http_request_cache.go index 5992fbf..f850a35 100644 --- a/internal/nodes/http_request_cache.go +++ b/internal/nodes/http_request_cache.go @@ -208,11 +208,15 @@ func (this *HTTPRequest) doCacheRead() (shouldStop bool) { } // 设置cache.age变量 - this.varMapping["cache.age"] = strconv.FormatInt(reader.ExpiresAt()-utils.UnixTime(), 10) + var age = strconv.FormatInt(reader.ExpiresAt()-utils.UnixTime(), 10) + this.varMapping["cache.age"] = age if addStatusHeader { this.writer.Header().Set("X-Cache", "HIT, "+refType+", "+reader.TypeName()) } + if this.web.Cache.AddAgeHeader { + this.writer.Header().Set("Age", age) + } // ETag // 这里强制设置ETag,如果先前源站设置了ETag,将会被覆盖,避免因为源站的ETag导致源站返回304 Not Modified