go-gitea / gitea

Git with a cup of tea! Painless self-hosted all-in-one software development service, including Git hosting, code review, team collaboration, package registry and CI/CD
https://gitea.com
MIT License
44.15k stars 5.41k forks source link

Server-timing headers #16747

Open clarfonthey opened 3 years ago

clarfonthey commented 3 years ago

It would be nice if we could enable the option for gitea to serve Server-Timing headers with responses, as it would be very helpful with debugging.

The option SHOW_FOOTER_TEMPLATE_LOAD_TIME should be incorporated into this instead, as more data can be included with the timing and it doesn't add information in user-visible areas.

zeripath commented 3 years ago

The only way a Server-Timing header can give the correct value is if the all of the content is pre-rendered before writing to the response. I don't think that's guaranteed.

clarfonthey commented 3 years ago

True, then I guess that template rendering time should be a separate option. But we can still separate DB latency, etc. in the header.

Actually, this is possible with HTTP trailers. So, technically they wouldn't be headers, but you could still include the "headers" after the response has been rendered. This would strictly require HTTP/2 for this feature, but I think that's reasonable for a feature that will likely only be enabled when debugging. Plus, you could just choose to not emit the trailer if HTTP/2 isn't used anyway.