2

I want to be able to auto-version these in SharePoint and I'm looking for the best solution.

SharePoint does it with some of it's files. For example:

<link rel="stylesheet" type="text/css" href="/_layouts/1033/styles/Themable/search.css?rev=Uoc0fsLIo87aYwT%2FGX5UPw%3D%3D"/> 

Notice this ?rev=Uoc0fsLIo87aYwT%2FGX5UPw%3D%3D at the end of the URL.

I want to do the same with my custom css and js, but can't find the right control to make this happen besides manually modifying the extension.

Basically to force browser cache to invalidate when a new CSS or js is changed. No more CTRL-F5 for a user to ensure they have the latest.

Another SO question on what this is: https://stackoverflow.com/questions/438821/what-does-do-in-a-css-link/438828#438828

I've looked at controls such as CSSRegistration.Register(), but there doesn't appear to be an option.

3
  • Will this be on an aspx page? Commented Jun 16, 2011 at 18:45
  • Yes, a master page or aspx page.
    – Shane
    Commented Jun 16, 2011 at 19:41
  • What is outputting the links to those files, is it a web part or a custom master page or something else?
    – Ryan
    Commented Jun 17, 2011 at 6:30

2 Answers 2

2

You should be able to version your custom assets using the Publishing Features of SharePoint Server

3
  • I don't mean just keeping a version for the usual versioning in a document library, but including it in a master page for example, such as: <link rel="stylesheet" type="text/css" href="/Style Library/Custom.css?rev=Uoc0fsLIo87aYwT%2FGX5UPw%3D%3D"/> so that that rev tag ensures a user is always downloading the current CSS.
    – Shane
    Commented Jun 16, 2011 at 17:11
  • Hm. I would think that any time you reference a document inside of a document library that includes versioning, it will always return the most recent version. That seems like it would be default behavior. Commented Jun 16, 2011 at 17:16
  • If it's cached on the client machine that's not always true. Commented Jun 16, 2011 at 18:43
0

Can you do something like this if you can edit the ASPX page:

<script type="text/javascript" href="/project/JS/myJSFile.js?rev=<%= DateTime.Now.Ticks.ToString() %>"></script> 
1
  • that would make it different every single time, therefore the javascript file would never cache. We want it to cache unless we rebuild and solution and push it out again.
    – Shane
    Commented Jun 16, 2011 at 19:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.