rstacruz / sinatra-assetpack

Package your assets transparently in Sinatra.
http://ricostacruz.com/sinatra-assetpack/
MIT License
542 stars 96 forks source link

Asset host support #27

Closed titanous closed 11 years ago

titanous commented 13 years ago

Allows setting an asset host like this:

assets {
  host 'cdn.example.org'
}

Which will prefix all asset urls in production with //cdn.example.org. I've also changed the cache buster to MD5 so that files can be versioned properly on CDNs as the mtime is server-specific.

Closes #4.

rstacruz commented 12 years ago

Great idea on the MD5... I guess I (and most people) never felt the issue as Git already assures consistent mtimes. Shall review it in the next few days.

rstacruz commented 12 years ago

I'd like to implement some sort of caching here, though. It seems it will do File.read too many times. Perhaps some sort of cache with the filename+mtime as it's key would suffice (general idea being if the file is not modified, then it's MD5 won't change too).

titanous commented 12 years ago

Yeah, I noticed that and haven't gotten around to it. The app I'm using is heavily cached so it's not a big deal for me.

nanodeath commented 12 years ago

It'd be great to see some movement on this issue, it's something I'm interested in as well...

niko commented 12 years ago

To me it looks like adding asset-host support to the helpers and being able to customize the hash algorithm for the cache buster are two separate issues. Other than that: I'd welcome both features! :)

mmmurf commented 12 years ago

on Heroku ENV['COMMIT_HASH'] returns the sha of the deployed version of the code.

titanous commented 12 years ago

Great, that must be newish, there have been requests for a while.

elephant commented 12 years ago

Any update on this?

nanodeath commented 12 years ago

This is, of course, far from a universal solution, but I discovered that CloudFlare (which replaces your nameservers) will automatically cache assets for you. Might be a reasonable interim solution for some.

icco commented 11 years ago

+1

syelle commented 11 years ago

We're also interested in asset host configuration as well as the MD5 hash for cache-busting. We have an additional need to configure multiple asset hosts as well that are selected based on a hash of the file.

j15e commented 11 years ago

Added your commit to feature/md5-hosts branch. Some issues to be fixe before release but it should definitively make it soon. See #71 for ongoing discussion.