From 71f9c77ee1796bebd4d1ebbced1c0caacd9c81c3 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Sun, 16 Nov 2025 11:49:06 -0500 Subject: [PATCH] RequestServer: Remove headers exempted from storage from in-memory cache We previously excluded headers exempted from storage when we serialized the headers into the database. However, we stored the original headers in-memory. So when a subsequent request hit CacheIndex::find_entry, we would return an entry with response headers that should have been excluded. --- Services/RequestServer/Cache/CacheIndex.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Services/RequestServer/Cache/CacheIndex.cpp b/Services/RequestServer/Cache/CacheIndex.cpp index 47cbd8046bf..90235940527 100644 --- a/Services/RequestServer/Cache/CacheIndex.cpp +++ b/Services/RequestServer/Cache/CacheIndex.cpp @@ -18,9 +18,6 @@ static ByteString serialize_headers(HTTP::HeaderMap const& headers) StringBuilder builder; for (auto const& header : headers.headers()) { - if (is_header_exempted_from_storage(header.name)) - continue; - builder.append(header.name); builder.append(':'); builder.append(header.value); @@ -116,6 +113,15 @@ void CacheIndex::create_entry(u64 cache_key, String url, HTTP::HeaderMap respons { auto now = UnixDateTime::now(); + for (size_t i = 0; i < response_headers.headers().size();) { + auto const& header = response_headers.headers()[i]; + + if (is_header_exempted_from_storage(header.name)) + response_headers.remove(header.name); + else + ++i; + } + Entry entry { .cache_key = cache_key, .url = move(url),