From a71ff521aae3ad606718e5aeefc99247e5c894fc Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Fri, 3 Apr 2026 09:56:39 +0200 Subject: [PATCH] cache: add debug log with no store reason --- src/network/cache/Cache.zig | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/src/network/cache/Cache.zig b/src/network/cache/Cache.zig index f8b2a9d4..d270310e 100644 --- a/src/network/cache/Cache.zig +++ b/src/network/cache/Cache.zig @@ -17,6 +17,7 @@ // along with this program. If not, see . const std = @import("std"); +const log = @import("../../log.zig"); const Http = @import("../http.zig"); const FsCache = @import("FsCache.zig"); @@ -171,11 +172,33 @@ pub fn tryCache( has_set_cookie: bool, has_authorization: bool, ) !?CachedMetadata { - if (status != 200) return null; - if (has_set_cookie) return null; - if (has_authorization) return null; - if (vary) |v| if (std.mem.eql(u8, v, "*")) return null; - const cc = CacheControl.parse(cache_control orelse return null) orelse return null; + if (status != 200) { + log.debug(.cache, "no store", .{ .url = url, .code = status, .reason = "status" }); + return null; + } + if (has_set_cookie) { + log.debug(.cache, "no store", .{ .url = url, .reason = "has_cookies" }); + return null; + } + if (has_authorization) { + log.debug(.cache, "no store", .{ .url = url, .reason = "has_authorization" }); + return null; + } + if (vary) |v| if (std.mem.eql(u8, v, "*")) { + log.debug(.cache, "no store", .{ .url = url, .vary = v, .reason = "vary" }); + return null; + }; + const cc = blk: { + if (cache_control == null) { + log.debug(.cache, "no store", .{ .url = url, .reason = "no cache control" }); + return null; + } + if (CacheControl.parse(cache_control.?)) |cc| { + break :blk cc; + } + log.debug(.cache, "no store", .{ .url = url, .cache_control = cache_control.?, .reason = "cache control" }); + return null; + }; return .{ .url = try arena.dupeZ(u8, url),