This repository was archived by the owner on Sep 3, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ export default {
16
16
server: {
17
17
port: 8000 , // default: 3000
18
18
host: ' 0.0.0.0' , // default: localhost,
19
+ timing: false
19
20
}
20
21
}
21
22
```
@@ -47,3 +48,55 @@ export default {
47
48
}
48
49
}
49
50
```
51
+
52
+ ## timing
53
+
54
+ - Type: ` Object ` or ` Boolean `
55
+ - Default: ` false `
56
+
57
+ Enabled ` server.timing ` option (disabled by default) adds a middleware to measure SSR generate time and add it to headers ('Server-Timing')
58
+
59
+ ### Example using timing configuration
60
+
61
+ ` server.timing ` can be an object for providing options. Currently supported one is total.
62
+
63
+ ``` js
64
+ export default {
65
+ server: {
66
+ timing: {
67
+ total: true
68
+ }
69
+ }
70
+ }
71
+ ```
72
+
73
+ ### Using timing api
74
+
75
+ ` timing ` api is also injected into ` response ` in server side when ` server.time ` is enabled.
76
+
77
+ #### Syntax
78
+
79
+ ``` js
80
+ res .timing .start (name, description)
81
+ res .timing .end (name)
82
+ ```
83
+
84
+ #### Example using timing in servermiddleware
85
+
86
+ ``` js
87
+ export default function (req , res , next ) {
88
+ res .timing .start (' midd' , ' Middleware timing description' )
89
+ // server side operation..
90
+ // ...
91
+ res .timing .end (' midd' )
92
+ next ()
93
+ }
94
+ ```
95
+
96
+ Then ` server-timing ` head will be included in response herder like:
97
+
98
+ ``` bash
99
+ Server-Timing: midd; desc=" Middleware timing description" ; dur=2.4
100
+ ```
101
+
102
+ Please refer [ Server-Timing MDN] ( https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Server-Timing ) for more details.
You can’t perform that action at this time.
0 commit comments