How do I do gzip and / or brotli compression for data in CloudFlare Workers?
Would like to compress and output the data in gzip or brotli.
How do I get it done?
How do I do gzip and / or brotli compression for data in CloudFlare Workers?
Would like to compress and output the data in gzip or brotli.
How do I get it done?
It does that automatically, but it should only compress when it is more efficient. Something below 1kb there is no gain. What is your output size?
it doesnt do that automatically.
are you sure it does?
i stored response.text() inside a kv, and use the below to return and it doesnt seem to automatically compress the output
return new Response(clonedResponse.body, response)
not really sure how to double confirm this but some of the output generated is actually text/html raw without compression. 65kb to 150kb
@harris reply at Cloudflare 503 Status Maintenance Page worker compressed HTML response? helped me
HTH