Skip to Content
Senri

Server-Timing

Put the time of each layer in the Server-Timing header

In development mode, responses get a Server-Timing header. The time of each layer appears in the browser's developer tools under Network → Timing.

import {  } from "@senrijs/senri";
import {  } from "@senrijs/senri/dev";

const  = ({ : () });

.(async function (, ) {
    await ();
});
.("/users/:id", ({  }) => ({  }));
server-timing: senri-1;desc="1. auth (self 0.27ms)";dur=1.49, senri-handler;desc="GET /users/:id";dur=1.17, senri-total;desc="total";dur=3.37
  • From the top, the entries go from the outside of the onion to the inside. Outer layers are longer (they include the inner ones)
  • The desc of middleware includes its own time (self)
  • The names start with senri-. A Server-Timing the app set itself is kept, and these are added after it

To see it nested, use the onion timeline.

Server-Timing is added only to requests that get development output (Using devtools()). It is never added in production.