News for hackers. Stuff that matters.
Re:Git Push Heroku Master: Now 40% Faster by d0m on Tuesday February 11, 2014 @02:52PM (#7219934)
That's great!

My biggest problem right now in term of deployment time is to sync with amazon for the assets. It literally takes 5 minutes for a small website..

Re:Git Push Heroku Master: Now 40% Faster by nthj on Tuesday February 11, 2014 @02:57PM (#7219971)
Yeah, that's frustrating. I might suggest you just serve them from your app [1], and use CloudFront with a custom origin to take over from there. I can deploy a Rails 4 app in ~20 seconds.

[1] http://guides.rubyonrails.org/configuring.html#rails-general...

Re:Git Push Heroku Master: Now 40% Faster by friism on Tuesday February 11, 2014 @03:15PM (#7220087)
At Heroku we now [recommend using AWS CloudFront][1] to serve assets, backed by your app running on Heroku instead of with S3. It's a much simpler setup with less state and fewer moving parts - and builds are faster :-).

[1]: https://devcenter.heroku.com/articles/using-amazon-cloudfron...

Re:Git Push Heroku Master: Now 40% Faster by ikawe on Tuesday February 11, 2014 @09:15PM (#7222072)
Thanks, really happy to see this is the officially recommend approach.

I've been doing it, but got some uncomfortable knee-jerk reactions from other developers, e.g. "But you should NEVER serve static assets directly!!!".

...but it's only served once!

Re:Git Push Heroku Master: Now 40% Faster by nthj on Tuesday February 11, 2014 @09:19PM (#7222096)
> e.g. "But you should NEVER serve static assets directly!!!".

As with music, painting, and architecture, any development-related NEVERS require that we understand the why, so we can know when to break the rule.

Re:Git Push Heroku Master: Now 40% Faster by beambot on Tuesday February 11, 2014 @04:46PM (#7220701)
Isn't this still problematic with SSL? Last time I checked, you had to pay $600/mo for a custom CloudFront SSL cert if you wanted to pass through the credentials from your own domain.

(Using mixed http/https was not an option.)

Re:Git Push Heroku Master: Now 40% Faster by friism on Tuesday February 11, 2014 @05:15PM (#7220877)
It's true that this is a problem if you insist on serving your CDN assets a custom domain CNAME mapped to CloudFront (i.e. https://assets.mydomain.com/). It doesn't cost extra if you just use the default CloudFront distribution URL, i.e. https://d3vam04na8c92l.cloudfront.net/stylesheets/applicatio...

This is not entirely clear from the Heroku docs, I'll ping the maintainer for an update.

Re:Git Push Heroku Master: Now 40% Faster by nthj on Tuesday February 11, 2014 @09:22PM (#7222102)
One cool trick for serving mixed http/https that I somehow went 10 years without finding out: you can just point your Rails asset_host to "//d3vam04na8c92l.cloudfront.net". Browsers understand this to mean "Look up this address via whatever protocol I am currently on, http if http, https if over SSL."

This is a huge cache boost in Rails because you don't have to cache your pages twice (once for HTTP once for HTTPs.)

Re:Git Push Heroku Master: Now 40% Faster by girvo on Wednesday February 12, 2014 @04:32AM (#7223369)
Oh god.. While your post is cool, I reacted violently to the "One cool trick..." part at the beginning.

Upworthy, you've broken me.

Re:Git Push Heroku Master: Now 40% Faster by sanderjd on Tuesday February 11, 2014 @09:39PM (#7222189)
Is there any real downside to this approach, or is it just that it looks "less professional"?
Re:Git Push Heroku Master: Now 40% Faster by neilmiddleton on Wednesday February 12, 2014 @05:33AM (#7223556)
No, you're still serving the same assets. It's only really an issue if your users like seeing where network requests are going and spot the cloudfront URL.
Re:Git Push Heroku Master: Now 40% Faster by espeed on Tuesday February 11, 2014 @08:39PM (#7221925)
Does Google have something like CloudFront for Compute Engine? Google gives you edge-cache for free if you use App Engine, but what about GCE?
Re:Git Push Heroku Master: Now 40% Faster by kmtrowbr on Tuesday February 11, 2014 @03:33PM (#7220227)
I have been using this asset_sync gem (with Ruby on Rails), together with S3 & Cloudfront, for 2 years and it works wonderfully: https://github.com/rumblelabs/asset_sync

I basically never think about deploying assets. It nearly always just works.

Re:Git Push Heroku Master: Now 40% Faster by josephlord on Tuesday February 11, 2014 @08:04PM (#7221798)
It works but they are a bit slow on merging pull requests. I'm currently using a fork so that CORS can work on Rackspace. I think this sort of issue is why Heroku no longer recommend this approach.
Re:Git Push Heroku Master: Now 40% Faster by neilmiddleton on Wednesday February 12, 2014 @05:34AM (#7223560)
It's not recommended as asset precompilation usually requires access to the environment (e.g a DB connection), and thus isn't deterministic.
Re:Git Push Heroku Master: Now 40% Faster by aantix on Tuesday February 11, 2014 @04:52PM (#7220739)
Something isn't right. Sounds like you're recalculating the cache digests each time..

Make sure you have your cache store set to dalli (production.rb)

      config.assets.cache_store = :dalli_store
Re:Git Push Heroku Master: Now 40% Faster by sleepyhead on Wednesday February 12, 2014 @07:45AM (#7223950)
Don't sync. Compile on deploy and let Cloudfront fetch when needed. It should also be possible to cache assets in memcache instead of compiling on each deploy (personally I ran into some issues with it but can't recall why).
Re:Git Push Heroku Master: Now 40% Faster by riffraff on Tuesday February 11, 2014 @04:14PM (#7220505)
that seems like a lot of time for a small website. Are you re-uploading the assets all the time?
Re:Git Push Heroku Master: Now 40% Faster by dataviz on Tuesday February 11, 2014 @03:03PM (#7220010)
Have you tried dedicated CDN service?