Whether or not to enable compression when forwarding domain via CloudFront


#1

In the post “How To: Configure a Custom Domain for HyperDev Projects”, the recommended settings include not caching, which means we don’t get any Gzip compression:

Is there a reason for this? Will it break things if we enable it?


#2

It should be fine to enable, and is probably a good idea for Gomix apps in the default configuration.

There are a lot of settings for CloudFront and it can be somewhat overwhelming. The two extremes can be thought of as “forward everything to the origin and cache nothing” or “forward the minimum and cache a lot”. The optimal settings depend on which features of HTTP requests your app uses. If your app uses query strings, and you know exactly which ones, specifying them explicitly will allow CloudFront to cache better but you’ll need to remember to update your CloudFront distribution if you change them.

The important thing is to test your app through the CloudFront distribution, logging which headers and parameters are received can be a big help in ensuring that CloudFront is forwarding what you expect. Also, examining the response headers in your browser’s dev tools will let you see what caching duration is being set by CloudFront. I’d also recommend setting the default cache duration to something lower like 300 or 600 so you don’t have to wait a day if you accidentally cache a response or update your app.

So… short answer: enabling compression is probably a good idea; long answer: CloudFront is complicated, but feel free to ask if you get stuck and have any further questions. Bonus answer: we have custom domains on our road map which should make this much easier at some point, but unfortunately we don’t have a specific time frame we can share.


#3

Awesome, thanks Daniel! Most of the other default settings in that post made a lot of sense to me, so I was surprised to see the compression disabled by default–which is why I wanted to check if there’s something GoMix-specific there. I very much appreciate the explanation!