Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 157 Stack Exchange communities.

What is meta?
Here's how it works:
  1. Any Stack Exchange user can ask a question
  2. The community provides support, votes on ideas, and reports bugs
  3. Your voice helps shape the way Stack Exchange operates

So we all know by now that all static content for Stack Exchange is kept on

My question is about the details of the versioning. Let's take a look at the current (as of the time of this question being posted) source to the master.js file on Stack Overflow (emphasis mine):

The querystring is of particular interest here. The first question is, why is it here?

The assumption is to enable versioning; because all of the content is long-lived (through the use of Cache-Control: max-age=604800), the assumption is that without such a querystring, the browser would never make a request for the new content if it is updated.

That leads into the second question. Assuming the above assumption is correct, how is the version generated? I'd imagine it would be a PITA to manually create these every time the page is updated, so I assume there is some sort of automated process behind it.

Thinking about it, it would seem to me that you can probably mirror the files on the main SO site (not for serving, mind you) and then generate this timestamp based on the last modified date of the file that is being served up when you write the url.

My guess is that it is not a hash of anything (unless the number of hash values exceeds the number of values being hashed), but rather some sort of encoding.

If so, what is the agorithm that you use to generate these version numbers?

Or am I completely off track here?

share|improve this question
P.S. If anyone finds it appropriate and wants to tag this with "" and/or "static-content" or something similar, by all means, I welcome it (sadly, I cannot, given my rep). – casperOne Oct 26 '10 at 20:31
up vote 4 down vote accepted

That simply comes from Mercurial. It used to be a revision number when they used SVN.

It is needed because otherwise people wouldn't receive the new javascript and css files immediately unless they refreshed the page, but instead only when the cache expired.

share|improve this answer
@Kop: I believe I mentioned that, but what it doesn't answer is how does the version number get changed on the referencing page. Surely they don't do it manually/by hand? – casperOne Oct 26 '10 at 22:26
@casper: there are several ways to do that; the easiest one would be to have the page open the internal files in the repository and pull the version from there. – Andreas Bonini Oct 26 '10 at 23:52
@Kop: What if there is no internal repository? – casperOne Oct 27 '10 at 1:45
@caspter: what do you mean? – Andreas Bonini Oct 27 '10 at 2:07
@Kop: Well, I am not using Mercurial or any repository for source right now, but I have to handle versioning of the files so that I can invalidate the cache when the files that make up the stiched file are changed. – casperOne Oct 31 '10 at 7:25
@Kop: I ended up going with Combine and that handles the version number quite nicely; I'm currently have it on my static-only site and it has helped tremendously. – casperOne May 25 '11 at 12:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .