nuxt-multi-cache icon indicating copy to clipboard operation
nuxt-multi-cache copied to clipboard

h3-compression is very slow

Open TimGonnet opened this issue 8 months ago • 1 comments

Hello

We use your package in production. We still have some latency with page cache, like 400ms in local. We discovered that it was because of the compression method recommended in your wiki. By default, h3-compression uses the maximum quality parameter for brotli compression, resulting in decent compression but very very slow. We reimplemented by hand the compression, and we manage to get 20ms brotli compression. So 20ms * 10ms with page cache instead of 400+.

You shouldn't recommend using this package in your wiki.

I have forked the repo, you can use it as it is: https://github.com/TimGonnet/h3-fast-compression?tab=readme-ov-file#benchmarks

Or recommend this code: https://github.com/TimGonnet/h3-fast-compression/blob/e94f9b2bfd0e0790fb19afd83e05aa9350f01f91/src/helper.ts#L38C1-L67C2

TimGonnet avatar Apr 06 '25 15:04 TimGonnet

Thank you for bringing this to my attention. Personally I don't use any compression at this level but instead handle it via nginx or varnish.

I originally added it to the docs because there was a bug report that route cache + compression doesn't work. Looking at your benchmarks the differences are quite huge, so I will gladly link to your version! I will also add a test case in the module to make sure it also works with your module.

dulnan avatar Apr 26 '25 09:04 dulnan

Added this in the docs, in addition to writing a test case using this library.

dulnan avatar Jul 13 '25 15:07 dulnan