title: Is this a safe, inexpensive way to do auto-versioning on an ASP.NET web page? Or will it bite me?
body: <p>I've got an ASP.NET web page where I want to ensure users get the latest version of the javascript file each time they load the page, but I do not want them to download the file unless it's actually changed.  It is a continually evolving web app and the js files get modified frequently. I have a version number in the url that I update manually.  But I keep forgetting to update it when I change the js file.</p>
  
  <pre><code>&lt;script type="text/javascript" src="js/Sched.js?v=1"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>So doing some searching for auto-versioning methods, I found one using re-writes and php, which made me think about my environment.  The only thing I came up with was to use the LastWriteTime of the js file for the version.  So I built a function:</p>
  
  <pre><code>    protected string GetFileTime(string file)
      {
          FileInfo fi = new FileInfo(Server.MapPath(file));
          if (fi.Exists)
          {
              Debug.WriteLine(fi.FullName);
              return fi.LastWriteTimeUtc.ToFileTime().ToString();
          }
          else
          {
              Debug.WriteLine("0");
              return "0";
          }
      }
  </code></pre>
  
  <p>And changed my script url in the page:</p>
  
  <pre><code>&lt;script type="text/javascript" src="js/Sched.js?dev=&lt;%= GetFileTime("js/Sched.js") %&gt;"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>It seems to work great on my dev server. The browser sees this:</p>
  
  <pre><code>&lt;script type="text/javascript" src="js/Sched.js?dev=131969009464369343"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>I've tested it with many page loads and the number remains the same until I make a change to the file.</p>
  
  <p>So it seems like a great solution. I've looked at FileInfo and it reads the file meta data from the disk and does not open or lock the file.  But when I put it live on the production server with about 1000 users, is there a possibility of performance or other issues?</p>