From e9340c70f9494f9e10a429f0e7adb7bf133f76a1 Mon Sep 17 00:00:00 2001 From: XOF Date: Mon, 15 Dec 2025 06:02:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20proxy/handler.go?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- proxy/handler.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/proxy/handler.go b/proxy/handler.go index 261a1c5..d9cd62a 100644 --- a/proxy/handler.go +++ b/proxy/handler.go @@ -109,12 +109,12 @@ func (h *ProxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { return } - if entry := h.cache.Get(targetURL); entry != nil { + cacheKey := h.cache.GenerateKey(targetURL) + if entry := h.cache.Get(cacheKey); entry != nil { log.Printf("Cache HIT: %s", targetURL) h.serveCached(w, entry) return } - log.Printf("Cache MISS: %s", targetURL) proxyReq, err := http.NewRequest(r.Method, targetURL, r.Body) @@ -163,7 +163,7 @@ func (h *ProxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { headers[key] = values[0] } } - h.cache.Set(targetURL, body, headers) + h.cache.Set(cacheKey, body, headers) } h.sendResponse(w, resp, body)