The numbers in the url prevent the browser from caching images and
stylesheets. (Since it’s a different URL each time the browser assumes
they are different files.)
Actually, the numbers are there to make expiration easy while still
retaining maximum cachability.
So you setup your web server to cache all js, css, and images for 1
year. Now your users don’t have to spend precious sockets trying to
fetch all the assets on every page load. That means faster page views.
But how do you now let the user download new versions of the files you
just told his browser to cache for 1 year? That’s where the asset
magic number comes in. It’s actually a timestamp of the file.
So what you’ve done is say to the browser, cache forever the all.js
from 2006-12-12 (all.js?20061212). Now when you update all.js on
January 4th, the file will be linked up as all.js?20070104. To the
browser that’s a new file, thus it’ll fetch it again (and now save
that version for 1 year).
If you for whatever (crazy) reason do not want your users to cache
assets like this, you can set ENV[‘RAILS_ASSET_ID’] = “”. Then the
magic will be gone.