When I use the Rails app to directly serve my assets through the Heroku cedar stack (i.e. NOT via CDN), they automatically get gzip'd. (See my previous question about why I am confused by this.)
Now I'm trying to configure Cloudfront to serve these assets, and ideally I would like them to be gzip'd. From what I read, I thought that Cloudfront would pass Accept headers to my application, so they should be serviced by gzip'd if they are supported (the same as when you make a direct request to the asset on the hero). But this is not so. Asset titles look like this:
Age:510 Connection:keep-alive Content-Length:178045 Content-Type:text/css Date:Sun, 08 Jan 2012 18:55:13 GMT Last-Modified:Sun, 08 Jan 2012 18:42:34 GMT Server:nginx/0.7.67 Via:1.1 varnish, 1.0 7a0b4b3db0cc0d369fe1d6981bfb646a.cloudfront.net:11180 (CloudFront), 1.0 6af08f4042ec142b4b760ca4cd62041d.cloudfront.net:11180 (CloudFront) X-Amz-Cf-Id:2b205edf4e9ef000a31a0208ca68f4e15b746eb430cde2ba5cc4b7dff4ba41a76c24f43cf498be02,8d5863a42eea452f86831a02f3eb648b26fe07013b08b95950f15ef8ba275822e1eb3b7ed2550d01 X-Cache:Hit from cloudfront X-Varnish:2130919357
There is no mention of encoding here, and when I look at a simple file, it is not gzip'd. So I'm wondering what I need to do here so that CloudView requests the gzip'd version from my application so that it can serve this for the client.
This post says that you need to manually gzip and download the file, but I do not understand why this is necessary. Firstly, this is annoying, and two, will it not request the file in the same way as my browser directly? So why not just give it the gzip'd file, as it was by default in my application?
Any advice on gzip'ng to work properly would be great. I would not have to manually gzip my files and upload them if possible.
source share