How do I enable gzip compression on Spaces?

(I’m referring to the DigitalOcean Spaces + CDN Product)

How do I enable gzip compression on web assets that I have in my Space and using a CDN for? I’ve defined the Content-Encoding value to gzip and flushed the cache but it hasn’t worked.

Show comments

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.

Shame on you, digitalocean.

it’s 2019 and there is no gzip? Really?

Your “CDN” is useless, there is no way to serve static files. So why does it need for?

I know this is very sub-optimal, but I wrote a simple js code to gzip js files before pushing it to Spaces.

const gzipme = require('gzipme');
gzipme('filename', true); // true means overwrite on the file.
                    Bucket: bucketName,
                    Key: 'filename',
                    Body: base64data,
                    ACL: 'public-read',
                    ContentType: 'application/javascript;charset=utf-8', 
                    ContentEncoding: 'gzip', // important
                    CacheControl: 'max-age=86400' // optional
                }, function (resp) {
                    console.log('Successfully uploaded file:');

After doing this for all of my files, I purge CDN cache.

It works for me so far.

This comment has been deleted