Cache-control headers. Browsers won't cache indefinitely unless you ask them to.
src="foo.js?v=1", then src="foo.js?v=2", etc.
I'm sure people consider this a hack, so I'm open to hearing other suggestions.
It doesn't work for unversioned library code though where you want to automatically upgrade all users of your code as is the case with Twitter it looks like.