caddyserver / caddy

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
https://caddyserver.com
Apache License 2.0
55.57k stars 3.91k forks source link

{latency} placeholder should probably return 0ms instead of 0s (for lower than 1ms requests) #1988

Closed magikstm closed 6 years ago

magikstm commented 6 years ago

1. What version of Caddy are you using (caddy -version)?

0.10.10 (for Windows 7 x64)

2. What are you trying to do?

Test latency speed using {latency} placeholder.

3. What is your entire Caddyfile?

:2015 {
    root F:\caddy2\caddySites
    log / access_log "{remote} | {user} | {when} | {method} | {uri} | {proto} | {status} | {size} | {latency}"

    rewrite {
        to {path} {path}/ /maintenance.html /
    }
}

4. How did you run Caddy (give the full command and describe the execution environment)?

Double-click the .exe. (no additional commands)

5. Please paste any relevant HTTP request(s) here.

Some simple navigations and Ctrl-F5 refreshes.

6. What did you expect to see?

0ms for fast requests. (other requests are listed in ms such as 1ms, 5ms or 20ms)

It's a minor issue, but I think 0ms requests should be noted as being "0ms" instead of "0s" to use a common base.

It's kinda odd seeing 1ms, 5ms 7ms then 0s (for quick requests).

It's also kinda odd when both the {latency} and {latency_ms} placeholders are used and they return: latency: 0s latency_ms: 0

I'm also unsure the microsecond part in this function works: https://github.com/mholt/caddy/blob/master/caddyhttp/httpserver/replacer.go#L183 (I've not seen microsecond results locally.)

7. What did you see instead (give full error messages and/or log)?

0s for fast requests.

8. How can someone who is starting from scratch reproduce the bug as minimally as possible?

Navigate in a site with low latency locally.

mholt commented 6 years ago

I closed the related PR due to a possibility that this is likely a Windows issue more than a bug in Caddy. It should be reporting microseconds if your system clock ticked at all, if not milliseconds.