xperfcaddy

package module
v0.0.0-...-3fc5c0f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 1, 2025 License: MIT Imports: 8 Imported by: 0

README

Caddy X-Perf

A caddy module that will add x-perf-caddy header to all responses to indicate how much time the request has spent inside caddy.

Assuming your reverse_proxy upstream adds x-perf-upstream header, that information coupled with x-perf-caddy can help quickly diagnosing latency issues.

For example let us consider these cases where timings are in seconds:

duration in browser x-perf-caddy x-perf-upstream case
5 4 4 there is some network latency between browser and caddy
5 5 4 the upstream is overloaded. The request spent 1s inside caddy waiting for upstream to be available
5 5 - When you use response_header_timeout, this request spent all 5 seconds waiting for an upstream and then was returned with an error since nobody was avaiable. This can be used to make sure your backend does not get overloaded in case of spikes.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Middleware

type Middleware struct {
	// contains filtered or unexported fields
}

Middleware implements an HTTP handler that adds X-Perf-Caddy header with request timing information.

func (Middleware) CaddyModule

func (Middleware) CaddyModule() caddy.ModuleInfo

CaddyModule returns the Caddy module information.

func (*Middleware) Provision

func (m *Middleware) Provision(ctx caddy.Context) error

Provision implements caddy.Provisioner.

func (Middleware) ServeHTTP

func (m Middleware) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error

ServeHTTP implements caddyhttp.MiddlewareHandler.

func (*Middleware) UnmarshalCaddyfile

func (m *Middleware) UnmarshalCaddyfile(d *caddyfile.Dispenser) error

UnmarshalCaddyfile implements caddyfile.Unmarshaler. Syntax:

xperfcaddy

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL