Significance of 'encode gzip'

I tend to set up Caddyfile reverse proxy code blocks using this form:

sub.domain.com {
  encode gzip
  reverse_proxy http://10.1.1.3
}

…but this could be simplified to:

sub.domain.com {
  reverse_proxy http://10.1.1.3
}

Would there be a noticeable impact if encode gzip is left out of a code block? I sometimes see examples presented without some form of compression included. I was wondering whether it’s okay to leave it out, or is it best practice to leave it in?

It depends whether your proxy upstream compresses the responses itself or not.

If not, then it can help to have it to reduce the amount of data transferred.

If the proxy does already compresses the responses, then encode will do nothing. Caddy won’t double-encode the response.

Caddy will only encode responses if the client request had a matching Accepts-Encoding header anyways, so it’s pretty much always safe to have.

1 Like

This topic was automatically closed after 30 days. New replies are no longer allowed.