From ef4effc8a06ccd1c4fa6fd02ecc2cf735d421a57 Mon Sep 17 00:00:00 2001 From: Kashiwa <13825170+ksw2000@users.noreply.github.com> Date: Mon, 24 Feb 2025 15:12:47 +0800 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Refactor:=20Reduce=20the?= =?UTF-8?q?=20Memory=20Usage=20of=20ignoreHeaders=20(#3322)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ♻️ Refactor: reduce the memory usage of ignoreHeaders Co-authored-by: Juan Calderon-Perez <835733+gaby@users.noreply.github.com> --- middleware/cache/cache.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/middleware/cache/cache.go b/middleware/cache/cache.go index 723b5321..f4a8ee3e 100644 --- a/middleware/cache/cache.go +++ b/middleware/cache/cache.go @@ -35,17 +35,17 @@ const ( noStore = "no-store" ) -var ignoreHeaders = map[string]any{ - "Connection": nil, - "Keep-Alive": nil, - "Proxy-Authenticate": nil, - "Proxy-Authorization": nil, - "TE": nil, - "Trailers": nil, - "Transfer-Encoding": nil, - "Upgrade": nil, - "Content-Type": nil, // already stored explicitly by the cache manager - "Content-Encoding": nil, // already stored explicitly by the cache manager +var ignoreHeaders = map[string]struct{}{ + "Connection": {}, + "Keep-Alive": {}, + "Proxy-Authenticate": {}, + "Proxy-Authorization": {}, + "TE": {}, + "Trailers": {}, + "Transfer-Encoding": {}, + "Upgrade": {}, + "Content-Type": {}, // already stored explicitly by the cache manager + "Content-Encoding": {}, // already stored explicitly by the cache manager } var cacheableStatusCodes = map[int]bool{