timing()
Signature
Section titled “Signature”app.timing([options])Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
options | Object | Optional configuration object. |
options.headerName | string | Custom header name (default: 'Server-Timing'). |
options.precision | number | Decimal places for duration in milliseconds (default: 2). |
This middleware tracks the total time taken to process a request and returns it in the response via the Server-Timing header, complying with the W3C specification.
Modern browsers automatically parse this header and display backend execution times in their Network Developer Tools.
Examples
Section titled “Examples”// Default usageapp.timing();
// With 4 decimal places of precisionapp.timing({ precision: 4});Response Header
Section titled “Response Header”Format:
Server-Timing: total;dur=12.34