Zstd encode compression level setup

1. The problem I’m having:

How i can set up compression level for zstd encode type?

I make tests with zstd, zstd 6, zstd 11 and have same results with dile size.
In klauspost/compress (with hints from this forum post by @francislavoie ) i found levels in text notaion, but zstd best has no effect again.

Caddy version:

v2.7.6

System environment:

Ubuntu 22.04.4 LTS

My complete Caddy config:

website.ltd {
#...
	encode {
		#has no effect this variants:
		#zstd best
		#zstd 6 
		zstd
		br 6
		gzip 6
	}
#...
}

P.S. Thanks for awesomeness to all Caddy team and forum activists!

1 Like

Please completely fill out the help topic template as per the forum rules.

What did you try exactly? What’s your evidence that it’s not working? Show an example request with curl -v. Enable the debug global option. Show your Caddy logs.

Hi and thanks for quick answer. Sorry but i cant fill up help template more relevant info. i am new caddy user and many simple manipulations (log enable and more) are difficult to me. In addition, my fresh installed windows 11 curl said me curl: option --compressed: the installed libcurl version doesn't support this, and without this flag curl’s report not relevant to my tests.

But i have fresh Chrome (v122.0.6261.95) browser with zstd support (and even enabled additional manually with chrome://flags/#enable-zstd-content-encoding before and after repeate tests) and its inspector info much representative for me, see my compilation of screenshots on one image (cant embed image bacause of new user’s forum restrictions)

And this is comparison with brotli levels (whith works perfect), see results below/

Can you or anyone tell me if specifying the compression level for zstd should have an effect at all or if the level cannot be adjusted?

I tested the different settings that I specified above and checked the actual size of the compressed data through Chrome inspector. The compression level in all cases is approximately equal to brotli 5.

results table here

Unfortunately, I did not take screenshots and logs, as I thought that confirmation of the problem would not be necessary. in none of the caddy documentation examples did I find an explicit indication of the compression level, so is this possible or not?

You can use curl -vL --header "Accept-Encoding: gzip, deflate, br, zstd" https://your-server/path/to/document

1 Like

Zstd compression level is not supported for now. I’ll add support when I have time.

To be clear, the zstd library we’re using only supports configuring 4 levels.

2 Likes

Thanks for info. Since Chrome added zstd for desktop browsers by default (caniuse says about flag-enabled for v121 and 122 and without flags on v123+, but we see default support in real even on Chrome v121, and it means we can serve zstd to about 20% users), but broli level 6 is faster and we need zstd compression adjustment to be on the edge :rocket:

If i can help (with github issue star :slight_smile: or another way, beta test maybe) please let me know!

If you’d like to open an issue on GitHub about it, it would save us a bit of time writing it up.

Or you could take a shot at implementing the changes yourself, it should be pretty simple. We can help you with code review etc.

Hello, here is PR with solution: (it is tested and works ok, but just now not all github workflows done, ill fix it soon)

2 Likes

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