From ba96fbbc71e293a054daf0eddc6c59d056384427 Mon Sep 17 00:00:00 2001 From: andig Date: Thu, 9 Jan 2025 21:50:39 +0100 Subject: [PATCH] Plugins: share http cache (#18152) --- provider/http.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/provider/http.go b/provider/http.go index 4fca739d8..6bbe7ad52 100644 --- a/provider/http.go +++ b/provider/http.go @@ -34,6 +34,8 @@ func init() { registry.AddCtx("http", NewHTTPProviderFromConfig) } +var mc = httpcache.NewMemoryCache() + // Auth is the authorization config type Auth struct { Type, User, Password string @@ -101,9 +103,10 @@ func NewHTTP(log *util.Logger, method, uri string, insecure bool, cache time.Dur } // http cache - cacheTransport := httpcache.NewMemoryCacheTransport() - cacheTransport.Transport = p.Client.Transport - p.Client.Transport = cacheTransport + p.Client.Transport = &httpcache.Transport{ + Cache: mc, + Transport: p.Client.Transport, + } // ignore the self signed certificate if insecure {