General queries about the encode directive

Hi,

I have a couple of queries about the encode directive.

  1. Is there any reason not to enable gzip and zstd compression at the same time?
encode gzip zstd

At present, I just have gzip enabled. I understand that zstd is a compression algorithm developed by Facebook.

  1. Is there a reason why encode is not a global directive?

I just noticed I have it across every block in my Caddyfile. I guess another way to present this question is to ask ‘Is there a reason why I would not include the encode directive in a Caddy block?’

Not really, maybe if your system hardware isn’t as optimized for handling encoding workloads (cause it does take CPU resources). Basically, Caddy picks which one to use based on the ones the clients have in their Accepts-Encoding header. But this will all be significantly improved in v2.4.0 due to this PR

Because it’s a HTTP handler/middleware. You may need for certain situations to use matchers to control when to encode. Generally Caddy’s defaults for deciding this is fine, but the user should always have control of this, ultimately because it’s not a security issue that is worth Caddy having an opinion over. e.g. Caddy is very opinionated about TLS because security is important and users are generally too dumb to configure their servers correctly :joy: no offense to anyone reading this but it’s better to just make it stupidly easy.

Like I said, performance considerations, or whether your upstream already handles compression itself or if you need to serve precompressed content from file_server (which the above linked PR will make much easier)

1 Like

You’ve just described me :open_mouth: Thanks for making it stupidly easy :grinning:

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