Server-Timing
W3C Server-Timing response header builder. Lets the server describe per-request timing metrics (database query duration, downstream HTTP call latency, encryption time) so the browser's Performance API exposes them to client-side telemetry.
The header is a comma-separated list of name; dur= entries. Builder primitives are immutable per-request collectors that operators populate over the lifetime of the request and serialize at response-write time.
b.serverTiming.create() returns a per-request collector:
var timing = b.serverTiming.create(); timing.mark("db.query", 12.5, "user fetch"); timing.mark("encrypt", 3.1); res.setHeader("Server-Timing", timing.toHeader()); // → "db.query; dur=12.5; desc=\"user fetch\", encrypt; dur=3.1"
Use timing.measure(name, fn) to time an async operation inline:
var rows = await timing.measure("db.query", function () { return db.query("SELECT ..."); });
b.serverTiming.create() #
Return a per-request collector with mark / measure / toHeader methods. The collector is mutable + scoped to a single request; operators discard or stringify at response-write time. Throws server-timing/bad-name for non-token metric names and server-timing/bad-duration for non-finite negative duration.
var timing = b.serverTiming.create();
timing.mark("cache.lookup", 0.3);
var data = await timing.measure("db.query", function () { return db.query("..."); });
res.setHeader("Server-Timing", timing.toHeader());
b.serverTiming.entry(name, durationMs?, description?) #
Format a single Server-Timing entry without building a collector. Useful when the operator wants a one-shot header value without threading a collector through the request scope.
res.setHeader("Server-Timing", b.serverTiming.entry("db.query", 12.5));
// → "db.query; dur=12.5"
Last updated 2026-08-08T16:39:49.652Z by seeder.