From 6bdcaf6f835c32f3cbcda7250eddb6978f96ae6e Mon Sep 17 00:00:00 2001 From: wood chen Date: Sat, 10 May 2025 18:10:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=90=86=E5=93=8D?= =?UTF-8?q?=E5=BA=94=E5=A4=B4=E8=AE=BE=E7=BD=AE=EF=BC=8C=E5=B0=86"Proxy-Go?= =?UTF-8?q?-Cache"=E5=92=8C"Proxy-Go-AltTarget"=E7=9A=84=E5=80=BC=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E4=B8=BA=E6=9B=B4=E5=85=B7=E8=AF=AD=E4=B9=89=E7=9A=84?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=EF=BC=8C=E4=BB=A5=E6=8F=90=E9=AB=98=E5=8F=AF?= =?UTF-8?q?=E8=AF=BB=E6=80=A7=E5=92=8C=E4=B8=80=E8=87=B4=E6=80=A7=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/handler/mirror_proxy.go | 4 ++-- internal/handler/proxy.go | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/internal/handler/mirror_proxy.go b/internal/handler/mirror_proxy.go index 78dee6c..79f4286 100644 --- a/internal/handler/mirror_proxy.go +++ b/internal/handler/mirror_proxy.go @@ -125,7 +125,7 @@ func (h *MirrorProxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { if item.ContentEncoding != "" { w.Header().Set("Content-Encoding", item.ContentEncoding) } - w.Header().Set("Proxy-Go-Cache", "HIT") + w.Header().Set("Proxy-Go-Cache-HIT", "1") if notModified { w.WriteHeader(http.StatusNotModified) return @@ -149,7 +149,7 @@ func (h *MirrorProxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { // 复制响应头 copyHeader(w.Header(), resp.Header) - w.Header().Set("Proxy-Go-Cache", "MISS") + w.Header().Set("Proxy-Go-Cache-HIT", "0") // 设置状态码 w.WriteHeader(resp.StatusCode) diff --git a/internal/handler/proxy.go b/internal/handler/proxy.go index 9b0b178..1b56e4a 100644 --- a/internal/handler/proxy.go +++ b/internal/handler/proxy.go @@ -350,12 +350,13 @@ func (h *ProxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { if item.ContentEncoding != "" { w.Header().Set("Content-Encoding", item.ContentEncoding) } - w.Header().Set("Proxy-Go-Cache", "HIT") + w.Header().Set("Proxy-Go-Cache-HIT", "1") // 如果使用了扩展名映射的备用目标,添加标记响应头 if usedAltTarget { - w.Header().Set("Proxy-Go-AltTarget", "true") + w.Header().Set("Proxy-Go-AltTarget", "1") } + w.Header().Set("Proxy-Go-AltTarget", "0") if notModified { w.WriteHeader(http.StatusNotModified) @@ -383,12 +384,13 @@ func (h *ProxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { // 复制响应头 copyHeader(w.Header(), resp.Header) - w.Header().Set("Proxy-Go-Cache", "MISS") + w.Header().Set("Proxy-Go-Cache-HIT", "0") // 如果使用了扩展名映射的备用目标,添加标记响应头 if usedAltTarget { - w.Header().Set("Proxy-Go-AltTarget", "true") + w.Header().Set("Proxy-Go-AltTarget", "1") } + w.Header().Set("Proxy-Go-AltTarget", "0") // 设置响应状态码 w.WriteHeader(resp.StatusCode)