Version Control – Using Version Numbers in File Names

filesversion controlversioning

I see that some software have the version number included as a part of their file name, while others do not. I am more used to the latter type, and I think that is more popular, but I see the former type sometimes in javascript libraries. For example, jQuery's file name is like jquery-2.1.0.js instead of jquery.js. Whenever I update these types of files, I have to look for the places in other programs that load these files, and change the file name they refer to, and manually delete the older version of these libraries. That is inconvenient to me, so I rather rename the file to exclude the version number, and keep the file name referred to to not include the version number.

I suspect that these numbers are for some kind of version control, but am not clear when and how they are used.

  • What are the pros and cons for including version numbers in the file name?
  • Is there de facto consensus on which areas of software or languages use version number in the file name, and which areas/languages do not? If so, is there any rationare for that?

Best Answer

  1. It makes sense to specify the version you require. Behavior you may rely on could have changed, so newer is not always better. First, test whether a new version of a library works for you. Then, update explicitly.

  2. In the case of web resources, having the version be part of the filename is important in the context of caching. For static resources like jquery.js you will want a very long cache time before it's re-fetched. However, during an update you want your code to use the new version immediately, rather than having clients switch over to the new version during the next day or so. As foo-1.2.3.js is a different resource as foo-1.2.4.js, no caches will get in the way.