ejoubaud
ejoubaud

Reputation: 5241

Deploying Meteor on a CDN or S3

Is there a way to get the static assets generated by a Meteor app deployed on a CDN - or a static hosting solution like S3 - in order to improve loading speed and reduce hosting costs ?

Upvotes: 4

Views: 821

Answers (3)

David Weldon
David Weldon

Reputation: 64312

CloudFront

I've detailed how we accomplished this at Edthena in this post. The TLDR is:

Add this line somewhere in your server code:

WebAppInternals.setBundledJsCssPrefix(CDN_URL);

Where CDN_URL is your CloudFront URL (e.g. https://a27n0s89ik4xb3.cloudfront.net).

We kept the defaults when creating the CloudFront distribution except for the following:

Origin Domain Name: myapp.example.com
Origin ID: myapp.example.com
Viewer Protocol Policy: HTTPS Only
Compress Objects Automatically: yes

If you serve your own fonts, you can end up with cross origin errors (unless you use a font data URL). Josh Owens describes how to deal with that in his post.

CloudFlare

Have a look at Cloudflare Meets Meteor on the meteorhacks blog. If you happen to be a CloudFlare user, it's a pretty easy solution but you'll need to disable WebSockets (or pay a lot, or use a complex workaround).

Upvotes: 1

ejoubaud
ejoubaud

Reputation: 5241

If deploying through demeteorizer, it is pretty easy to upload the content of the static_cacheable to a CDN and change the links in app.html and app.json.

That process can probably be automated in a custom deploy/capistrano script.

Upvotes: 0

gabrielhpugliese
gabrielhpugliese

Reputation: 2588

If you are using meteorite, you can use this package: https://github.com/nate-strauser/meteor-aws-sdk

Upvotes: 0

Related Questions