Question

Why isn't my "Content-Encoding" header set?

I’m serving my next.js assets through spaces but the Response Headers don’t have a Content-Encoding header. I’ve confirmed the headers are set in the spaces file metadata. I tried precompressing and uploading my files to spaces but still no header.

Does DO spaces/CDN not support Content-Encoding?


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
November 13, 2023

Hi there,

As far as I can see, according to DigitalOcean’s documentation, the Spaces CDN endpoints may dynamically uncompress content if the original object has Content-Encoding: gzip and the client does not send an Accept-Encoding: gzip header.

If the CDN does decompress the content dynamically, it will remove the Content-Encoding: gzip header from the response​.

You can find more information about this here:

https://docs.digitalocean.com/products/spaces/how-to/set-file-metadata

Basically, if you’ve set the Content-Encoding header in your file metadata and it’s not appearing as expected, the CDN may not be altering or adding headers dynamically, which could be why you’re not seeing it in the response.

I believe that as of the time being, there is no way to force this.

Best,

Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel