Sevenforge Sevenforge by Curtis Spencer home

How Rails Calculates the Cache-Busting Asset ID

December 18, 2008

In asset_tag_helper.rb, you find this code:

def rails_asset_id(source)
  if asset_id = ENV["RAILS_ASSET_ID"]
    asset_id
  else
    path = File.join(ASSETS_DIR, source)

    if File.exist?(path)
      File.mtime(path).to_i.to_s
    else
      ''
    end
  end
end

Fork me on GitHub