Commit Graph
75 Commits
Author SHA1 Message Date
Karl Seguin 2e6999f20b chore: make declarations private if they don't need to be public
This change is 99%  s/pub//   + a handful of dead code removal.
2026-09-10 14:42:09 +08:00
Karl Seguin a5e27869d3 chore: remove unused imports 2026-09-05 17:51:47 +08:00
Karl Seguin decedca6e7 chore: Network cleanup
Network has accumulated a bit of bagged. It knows a lot about certificates, it
knows a lot of the cache. I have plans to expand Network, and wanted to clean it
up.

1 - certificate logic moved to dedicated Certificates.zig
2 - Removed CurlDebugAllocator
    - this makes setup easier, to Updater can just init libcurl directly
3 - Change Updater to be a single function
4 - Cache initialization is don in the Cache
5 - ?Cache => Cache{.kind = .noop}
2026-08-22 07:04:58 +08:00
Karl Seguin a3034105aa chore: Move cache maintenance to startup and browser.deinit
--http-cache-entry-limit is currently implemented as a hard-limit via a check
on every put. For a large --http-cache-entry-limit, this can result in a non-
trivial delay on every http get.

This commit calls cache.maintenance() on Browser.deinit and on startup.
maintenance:
1 - purges stale entries
2 - enforces the limit

With concurrent requests, the number of entries can easily exceed the limit by
hundreds of entries (but this is temporary).
2026-08-14 15:55:37 +08:00
Muki Kiboigo 32364a26da use proper default on http_cache_entry_limit option 2026-08-07 08:01:55 -07:00
Muki Kiboigo f80aa2882c use a better query for evictOverflow 2026-08-07 08:01:54 -07:00
Muki Kiboigo 4f5bcec9a6 add max entry limiting to SqliteCache 2026-08-06 13:29:22 -07:00
Muki Kiboigo bf35489192 add content_type column in Cache 2026-08-03 18:26:58 -07:00
Muki Kiboigo ea0a45c713 add format for SqliteCachePath 2026-08-03 18:26:58 -07:00
Muki Kiboigo 0b74224b15 use CachePutRequest for puts instead of CacheMetadata 2026-08-03 18:26:57 -07:00
Muki Kiboigo 65448bbde6 clear old non-Vary headers on renew 2026-08-03 18:26:13 -07:00
Muki Kiboigo 6c56144ef9 rework get to be strictly deferred 2026-08-03 18:26:12 -07:00
Muki Kiboigo d16408d2d8 add transaction begin types 2026-08-03 18:17:44 -07:00
Muki Kiboigo a03471a1ce add test for no validators behavior 2026-08-03 18:17:44 -07:00
Muki Kiboigo 8dc2488835 always defer conn.rollback after tx begin 2026-08-03 18:17:44 -07:00
Muki Kiboigo 65593179ea early exit on SqliteCache.get on expired without validators 2026-08-03 18:17:44 -07:00
Muki Kiboigo 3bfec6d7ff skip body dupe on expired without validators on Cache.get 2026-08-03 18:17:43 -07:00
Muki Kiboigo 04e93cd592 check vary before we dupe in SqliteCache.get 2026-08-03 18:17:43 -07:00
Muki Kiboigo 94c029ff32 get rid of file variant in CachedData 2026-08-03 18:17:43 -07:00
Muki Kiboigo a96543052c manually delete and reinsert 2026-08-03 18:17:43 -07:00
Muki Kiboigo 671b110aa2 loadBody can return null 2026-08-03 18:17:43 -07:00
Muki Kiboigo 4d59b61a33 remove primary key on url name 2026-08-03 18:17:43 -07:00
Muki Kiboigo 047280e0d6 use strict tables 2026-08-03 18:17:43 -07:00
Pierre Tachoire 1308639a9f cap delta-seconds values per RFC 9111
Huge max-age/Age header values previously either panicked in the
i64 casts when storing metadata, or were silently truncated to their
first 8 digits by the fixed-size lowercase buffer in
CacheControl.parse. Cap them at 2^31 as RFC 9111 §1.2.2 prescribes
and compare directives case-insensitively without truncation.
2026-08-03 18:17:42 -07:00
Muki Kiboigo 0f2957cda2 add SqliteCache as default local impl 2026-08-03 18:17:40 -07:00
Karl Seguin c726b022e8 tests: improve test output and test log handling
1 - TEST_VERBOSE is now off by default
2 - There's a afterEach callback that is automatically run after each tests, it:
     a - clears the log filters
     b - resets the test arena
3 - LogFilter replace with
     a - testing.silenceLog(&.{...scopes...}); to silence all logs for the given
         scopes.
     b - testing.expectLog(&.{...scopes}); to set log expectations, 1 per log.
         The goal here isn't so much to expect logs (though, you can do that),
         but rather to silence an expected # of logs, without silencing more.
2026-07-31 07:30:25 +08:00
Karl Seguin dcb98853b9 chore: make our use of clock/timestamp more consistent
Zig 0.16 changed clocks/timestamps. Our migration to Zig 0.16 took the path of
least resistance. For example, we kept 'monotonic' and 'real' even though Zig
0.16 renamed them to 'boot' and 'clock'

This commit tries to standardize all timestamp usage to: lp.datetime.timestamp
and lp.datetime.milliTimestamp using the new zig 0.16 names ('boot' and 'clock')
2026-07-27 09:28:48 +08:00
Karl Seguin 8e42d63c1c zig: Zig 0.16
Built against https://github.com/lightpanda-io/zig-v8-fork/tree/zig-0.16 but
it doesn't require a new v8 build.

Built against https://github.com/lightpanda-io/boringssl-zig/tree/zig-0.16
since the current fork we point to isn't updated.

A global std.Io instance, lp.io. Way easier this way and requires 0 changes to
our libcurl integration / event loop.

Network code uses a new layer that does what Zig 0.15's posix package used to
do. Again, quicker migration that way. But, as long as we have the global IO,
and given the half-baked nature of networking in std.Io 0.16, this just makes
sense. Things can be migrated as needed.

The std.time.* -> std.Io.Timestamp/Clock/Duration resulted in _a lot_ of
changes. ArrayList = .{} -> ArrayList -> .empty also resulted in a lot of
changes, but that's obviously superficial. As is the trimLeft/trimRight ->
trimStart/trimEnd rename.

Locking adopt the `Uncancelable` variants, e.g. mutex.lockUncancelable() to
preserve the error-free signature (and, because cancellation would be something
we'd have to put more thought into).

std.json.ObjectMap is now unmanaged, so the allocator had to be passed along.
However, there's still a deprecated managed variant of MemoryPool, so I switched
to it (we can do a small follow up PR to move to the unmanaged after).

I tried use_llvm = false, but it locks my computer, consuming RAM until MacOS
gives me a popup I've never seen before, begging me to start killing processes.

Agent and the networking stuff saw the most significant changes.
2026-07-22 13:26:03 +08:00
Muki Kiboigo 65cf678822 heuristically cache only with Last-Modified header 2026-06-30 09:49:01 -07:00
Muki Kiboigo f75b6f966b add simple 1 day heuristic cache 2026-06-28 14:09:52 -07:00
Muki Kiboigo 6433ca7df2 rename RenewRequest to RenewResponse 2026-06-17 20:32:58 -07:00
Muki Kiboigo 3091571b91 add tests for cache entry renewal 2026-06-16 22:35:42 -07:00
Muki Kiboigo 47483fd992 update more fields on renew 2026-06-16 22:13:08 -07:00
Muki Kiboigo 83a690cdf9 fix max-age tracking on no-cache directive 2026-06-15 07:20:18 -07:00
Muki Kiboigo 65c8d6fe21 update CacheControl test 2026-06-14 09:17:26 -07:00
Muki Kiboigo dd6dbd27da etag and last_modified null by default 2026-06-14 09:17:26 -07:00
Muki Kiboigo 2728cfc65e Cache.revalidate -> Cache.renew 2026-06-14 09:17:25 -07:00
Muki Kiboigo feefcd4650 Cache Revalidation 2026-06-14 09:16:33 -07:00
Muki Kiboigo a6c8a28977 add Cache.revalidate + supporting logic 2026-06-14 09:16:31 -07:00
Muki Kiboigo f0bc85f117 add Cache Eviction 2026-05-25 11:23:25 -07:00
Muki Kiboigo 14e1f1bcf6 add clear fn to Cache and FsCache 2026-05-07 09:00:33 -07:00
Karl Seguin 8509b112b8 Various small fixes
Extracted from https://github.com/lightpanda-io/browser/pull/2242
2026-04-25 13:22:41 +08:00
Karl Seguin 0a8f4ff75f Remove unused imports
As a general rule, I keep `std` if its there and unused, mostly for debug.print
debugging.
2026-04-23 16:21:56 +08:00
Karl Seguin 2d20e57f80 Change all @import("...../log.zig") to const log = lp.log;
@import("lightpanda") where needed.

Would also like to do this for String, Page, Session and js which all stand out
as types that are use across the codebase.

I know that a few devs are doing this in new work and I haven't heard anyone
voice an objection.
2026-04-20 12:40:04 +08:00
Karl Seguin 3be913750e Cache-Control is public by default
- If private isn't specified, default to public.
- Add some tests
- Optimize parsing by lower-casing once and switch to std.mem
2026-04-11 07:23:56 +08:00
Adrià Arrufat 182447c907 cache: add log filter to garbage file test 2026-04-08 19:36:29 +02:00
Pierre Tachoire a71ff521aa cache: add debug log with no store reason 2026-04-03 07:23:32 -07:00
Muki Kiboigo 13ea4d1ee3 more expressive cache logging 2026-04-03 07:23:32 -07:00
Muki Kiboigo 3d760e4577 add format to CachedMetadata 2026-04-03 07:23:31 -07:00
Muki Kiboigo a1a301666f dupe url in tryCache 2026-04-03 07:23:31 -07:00