Reputation: 5241
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
Reputation: 64312
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.
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
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
Reputation: 2588
If you are using meteorite, you can use this package: https://github.com/nate-strauser/meteor-aws-sdk
Upvotes: 0