How to Combine GZip + CDN for Fastest Page Loads
Friday, June 11th, 2010This is Article #3 of a 4-part series. For a good primer, check out the first two articles listed below. Otherwise, jump right in!
- The Importance of Page Load Speed
- Improve Page Load Speed (by 80%) by Improving Component Load Speed
- How to Combine GZip + CDN for Fastest Page Loads
- Pitfall of Amazon S3 + CloudFront as a CDN: No GZipping
- Possible Solutions (that don’t work)
- Intercept CloudFront requests with app server and rewrite
- Detect requests with Rails and write asset URLs accordingly
- The Solution: Hybrid Gzipping/CloudFront Depending on Asset-type
In my last post, I discussed the three techniques used to improve asset load speed. In this post, I will discuss how to combine the use of GZipping and a Content Delivery Network (CDN) for the fastest possible page loads.
Pitfall of Amazon S3 + CloudFront
Everyone’s favorite CDN these days is Amazon’s CloudFront service, which serves files directly from Amazon’s scalable “simple storage system”, Amazon S3. It is very easy to work with, has widespread support in Ruby gems and plugins (and countless other libraries), and is very inexpensive with it’s pay-as-you-go billing.
However, there is one large pitfall to using Amazon S3 + CloudFront, and that is that neither S3 nor CloudFront support GZip detecting and encoding. It would seem that we need to now decide whether we’ll do without GZipping or using a CDN. Not so! There is another way.

