更新 proxy/handler.go
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user