From e26a2001468167d8d4e37366feadb56c9ec3e932 Mon Sep 17 00:00:00 2001 From: Muki Kiboigo Date: Thu, 6 Aug 2026 13:01:50 -0700 Subject: [PATCH] add http cache entry limit options --- src/Config.zig | 8 ++++++++ src/help.zon | 3 +++ 2 files changed, 11 insertions(+) diff --git a/src/Config.zig b/src/Config.zig index 55968d4ee..8bdb18396 100644 --- a/src/Config.zig +++ b/src/Config.zig @@ -191,6 +191,7 @@ const CommonOptions = .{ .{ .name = "log_filter_scopes", .type = log.FilterRule, .multiple = true, .validator = logFilterScopesValidator }, .{ .name = "user_agent_suffix", .type = ?[]const u8 }, .{ .name = "http_cache_dir", .type = ?[]const u8 }, + .{ .name = "http_cache_entry_limit", .type = ?u32 }, .{ .name = "web_bot_auth_key_file", .type = ?[]const u8 }, .{ .name = "web_bot_auth_keyid", .type = ?[]const u8 }, .{ .name = "web_bot_auth_domain", .type = ?[]const u8 }, @@ -631,6 +632,13 @@ pub fn httpCacheDir(self: *const Config) ?[]const u8 { }; } +pub fn httpCacheEntryLimit(self: *const Config) u32 { + return switch (self.mode) { + inline .serve, .fetch, .mcp, .agent => |opts| opts.http_cache_entry_limit orelse 1000, + else => 1000, + }; +} + pub fn cookieFile(self: *const Config) ?[]const u8 { return switch (self.mode) { inline .serve, .fetch, .mcp, .agent => |opts| opts.cookie, diff --git a/src/help.zon b/src/help.zon index e88ede3b0..b530e957d 100644 --- a/src/help.zon +++ b/src/help.zon @@ -342,6 +342,9 @@ \\ Directory used as a filesystem cache for network resources. Omitting \\ this disables caching. \\ Defaults to no caching. + \\ --http-cache-entry-limit + \\ Maximum number of entries that can be stored in the HTTP cache. 0 means no limit. + \\ Defaults to 1000. \\ --http-connect-timeout \\ Time in ms to establish an HTTP connection before timing out. 0 means \\ never.