Skip to content
This repository has been archived by the owner on Sep 3, 2024. It is now read-only.

doc: server timing #1115

Merged
merged 1 commit into from
Jan 21, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions en/api/configuration-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default {
server: {
port: 8000, // default: 3000
host: '0.0.0.0', // default: localhost,
timing: false
}
}
```
Expand Down Expand Up @@ -47,3 +48,55 @@ export default {
}
}
```

## timing

- Type: `Object` or `Boolean`
- Default: `false`

Enabled `server.timing` option (disabled by default) adds a middleware to measure SSR generate time and add it to headers ('Server-Timing')

### Example using timing configuration

`server.timing` can be an object for providing options. Currently supported one is total.

```js
export default {
server: {
timing: {
total: true
}
}
}
```

### Using timing api

`timing` api is also injected into `response` in server side when `server.time` is enabled.

#### Syntax

```js
res.timing.start(name, description)
res.timing.end(name)
```

#### Example using timing in servermiddleware

```js
export default function (req, res, next) {
res.timing.start('midd', 'Middleware timing description')
// server side operation..
// ...
res.timing.end('midd')
next()
}
```

Then `server-timing` head will be included in response herder like:

```bash
Server-Timing: midd;desc="Middleware timing description";dur=2.4
```

Please refer [Server-Timing MDN](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Server-Timing) for more details.