Skip to content

Lightpanda: the headless browser designed for AI and automation

add http cache entry limit options

Muki Kiboigoe26a20014681
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 <INT>
+ \\ Maximum number of entries that can be stored in the HTTP cache. 0 means no limit.
+ \\ Defaults to 1000.
\\ --http-connect-timeout <INT>
\\ Time in ms to establish an HTTP connection before timing out. 0 means
\\ never.