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)