Last Updated: February 25, 2016
· richard

Don't upload assets (js/css) to S3 when using Cloudfront

Instead, just set a custom origin header on your Cloudfront distribution, and point it to your application.

- No need to pay for a S3 bucket.
- No need to upload assets to S3 during deploy.
- Possibly less gem dependencies.
- Possibility to serve gzipped assets depending on the Accept-Encoding header. (Why we moved to this solution at Mynewsdesk)

- Could mean slower initial requests if loading asset from a very remote location
- Need to distribute precompiled assets to all of your application nodes, if behind a load balancer.

Read more:

2 Responses
Add your response

We've used custom origin in a recent project and it is great!
It is worth noting that you should version your assets to avoid serving cached content from cloudfront.

<link rel="stylesheet" href=""/>

over 1 year ago ·

The other benefit is its easier to handle access-control-allow-origin issues with fonts and Firefox if serving from your app instead of S3

over 1 year ago ·