caddy/modules/caddyhttp
Julien Voisin 323e3fe4b7
encode: reduce allocations in AcceptedEncodings (#7847)
AcceptedEncodings runs for every request when response compression is enabled,
so its allocations contribute directly to per-request garbage and GC pressure.
While the gains are modest, this cuts allocations by two-thirds and bytes
nearly in half on a hot path that executes on every compressed request. Fewer
allocations means less work for the garbage collector, which at high request
rates translates into lower GC frequency and steadier tail latency, not just
faster execution of this one function in isolation.

For each token in the Accept-Encoding header it called strings.Split(accepted,
";"), allocating a throwaway slice per encoding, and grew the prefs slice from
empty. This commit replaces the per-token Split with strings.Cut (zero
allocation) and presize prefs from the comma count.

As requested per the policy, this commit adds a benchmark to exercise the
change. With header "gzip, deflate, br;q=0.9, zstd;q=0.8":

AcceptedEncodings
- sec/op  1158.5n -> 771.8n  (-33.38%)
- B/op 408 -> 216  (-47.06%)
- allocs/op 9 -> 3  (-66.67%)

Co-authored-by: @dunglas
2026-08-01 00:23:57 +10:00
..
caddyauth caddyhttp: use canonical header key casing to avoid re-canonicalization (#7911) 2026-07-30 20:40:35 +10:00
encode encode: reduce allocations in AcceptedEncodings (#7847) 2026-08-01 00:23:57 +10:00
fileserver browse: Update Caddy logo 2026-06-20 13:45:10 -06:00
headers
intercept intercept: fix misleading handle_response error for extra matcher args (#7871) 2026-07-12 09:16:34 +10:00
logging
map
proxyprotocol
push
requestbody
reverseproxy reverseproxy: fix broken reservoir sampling in random_choose policy (#7873) 2026-07-12 09:25:31 +10:00
rewrite rewrite: preserve non-canonical path encoding after uri replace (#7907) 2026-07-26 08:49:44 +10:00
standard
templates templates: Patch for GHSA-vcc4-2c75-vc9v (#7785) 2026-06-01 13:35:02 -06:00
tracing tracing: fix BatchSpanProcessor goroutine leak on config reload (#7826) 2026-06-18 11:42:58 -06:00
app.go caddyhttp: Document dropping underscore headers 2026-06-20 13:45:10 -06:00
autohttps.go
autohttps_test.go
caddyhttp.go
caddyhttp_test.go
celmatcher.go build(deps): bump cel-go from v0.28.1 to v0.29.2 (#7872) 2026-07-12 09:17:08 +10:00
celmatcher_test.go caddyhttp: add URL pattern request matcher (#7787) 2026-06-22 10:25:43 -06:00
errors.go
http2listener.go chore: clean up wording and typo fixes (#7745) 2026-05-20 16:36:30 +10:00
httpredirectlistener.go chore: clean up wording and typo fixes (#7745) 2026-05-20 16:36:30 +10:00
invoke.go
ip_matchers.go
ip_range.go
logging.go
marshalers.go
matchers.go caddyhttp: use canonical header key casing to avoid re-canonicalization (#7911) 2026-07-30 20:40:35 +10:00
matchers_test.go caddyhttp: fix path_regexp (MatchPathRE) Windows backslash bypass (#7858) 2026-07-11 08:37:44 +10:00
metrics.go
metrics_test.go
replacer.go caddyhttp: add {http.request.proto_name} placeholder for spec-compliant protocol names (#7782) 2026-06-04 11:03:19 -04:00
replacer_test.go caddyhttp: add {http.request.proto_name} placeholder for spec-compliant protocol names (#7782) 2026-06-04 11:03:19 -04:00
responsematchers.go
responsematchers_test.go
responsewriter.go
responsewriter_test.go
routes.go
server.go Set the QUIC InitialPacketSize to 1200 bytes (#7886) 2026-07-26 08:48:25 +10:00
server_test.go caddyhttp: New expected_underscore_headers server option (#7809) 2026-06-11 22:26:21 -06:00
staticerror.go
staticresp.go chore: fix sabotage spelling in nolint comments (#7892) 2026-07-18 08:14:38 +00:00
staticresp_test.go
subroute.go
urlpatternmatcher.go caddyhttp: add URL pattern request matcher (#7787) 2026-06-22 10:25:43 -06:00
urlpatternmatcher_test.go caddyhttp: add URL pattern request matcher (#7787) 2026-06-22 10:25:43 -06:00
vars.go caddyhttp: Clean up variable scope in vars matcher 2026-06-20 13:45:10 -06:00
vars_test.go