Asset combinator for rack
gem install rack-combobot
Point your frontend to /combobot?script1.js&script2.js
to get script1.js and script2.js combined.
require 'rack'
require 'rack-combobot'
require 'my-app'
use Rack::Combobot, :root => '/public'
run MyApp
In your config/application.rb
config.middleware.use 'Rack::Combobot', :root => "#{Rails.root}/public"
Add expires header
config.middleware.use 'Rack::Combobot', :root => "#{Rails.root}/public", :expires => Time.gm(2020)
To bust the cache, simple add a unique string to your request like so /combobot/BUSTINGSRING?script1.js&script2.js
.
If you environment doesn't allow having the file names in the query string (Like on CloudFront). Combobot will accept the file names as part of the url, but they have to start with &
.