Header Vary: Accept Encoding

Hi,

I would like to set vary header for certain filetype. How to do that with worker?

In Apache we do it like that. How to do that using worker?

<FilesMatch "\.(js|css|xml|gz|html|php|ttf|txt|woff|otf|ttf|eot|json)$">
	Header always append Vary "Accept-Encoding"
</FilesMatch>
1 Like

Workers always run in front of the Cloudflare cache, so adding a vary header won’t do anything. Could you explain more about what you’re trying to achieve or your current worker code (if any)?

Cloudflare will automatically compress content to end users when the client signals support for gzip (or Brotli) compression. Details available here.

There is an article by @junade that indicates adding the Accept-Encoding header will be ignored and removed, but that may not apply in a Worker.

Doing a quick test on a worker of my own, I see the vary response header when the client indicates gzip capability, and the originless response is compressed as expected.