caddy/modules
Julien Voisin 63f4e387c3
caddyhttp: allocate the request UUID lazily instead of on every request (#7936)
addHTTPVarsToReplacer ran SetVar(ctx, "uuid", new(requestID)) for every
request during replacer setup, allocating a *requestID unconditionally even
though it is only ever read by the {http.request.uuid} placeholder. The UUID
value itself was already generated lazily (requestID.String caches on first
call), but the container was not.

Allocate the *requestID on first access instead: the uuid placeholder now
creates and stores it in the request's vars table when absent, so repeated
references within a request still share one instance (and thus one UUID),
while requests that never reference the UUID pay nothing.

Add a benchmark for the per-request replacer setup and a regression test for
the uuid placeholder, which previously had no coverage.

Benchmark (BenchmarkAddHTTPVarsToReplacer, linux/arm64, count=6), common path
where the UUID is never referenced:

    before: ~700 ns/op   352 B/op   9 allocs/op
    after:  ~690 ns/op   336 B/op   8 allocs/op

One 16-byte allocation removed per request; a GC-pressure win rather than a
latency one.
2026-08-11 21:21:33 +10:00
..
caddyevents refactor: replace HasPrefix+TrimPrefix with CutPrefix (#7095) 2025-06-27 22:04:09 +03:00
caddyfs events: Refactor; move Event into core, so core can emit events (#6930) 2025-03-29 08:15:43 -06:00
caddyhttp caddyhttp: allocate the request UUID lazily instead of on every request (#7936) 2026-08-11 21:21:33 +10:00
caddypki pki: Handle error immediately after reading root from disk (#7896) 2026-07-19 23:59:46 -04:00
caddytls caddytls: skip idna.ToASCII for pure ASCII SNI values (#7770) 2026-05-28 11:18:09 +10:00
filestorage caddyfile: Normalize & flatten all unmarshalers (#6037) 2024-01-23 19:36:59 -05:00
internal/network network_proxy: reject proxy URLs that resolve to a port with no host (#7922) 2026-08-10 15:58:43 +10:00
logging log: support d (day) in roll_interval directive (#7900) 2026-07-22 01:39:33 +03:00
metrics metrics: scope metrics to active config, add optional per-host metrics (#6531) 2024-10-02 08:23:26 -06:00
standard filesystem: Globally declared filesystems, fs directive (#5833) 2024-01-13 20:12:43 +00:00